program ornamentas;

var
  mas : array [1..50,1..50] of boolean;         { Vis— langeli— masyvas }
  klaidos,x,y,a,b,c : integer;
  kamp : array [1..4] of boolean;           { 4 simetri˛k— langeli— masyvas }
  byla : text;
  ch : char;
  gerai : boolean;
  bx,by,          { Blogo langelio koordinat‚s   }
  cx,cy,          { Ornamento centro koordinat‚s }
  w ,h :integer;  { Ornamento plotis ir auk˛tis  }

begin
  assign(byla,'ORNAM.DAT');
  reset(byla);
  cy:=51; cx:=51;
  h:=0;   w:=0;
  for y:=1 to 50 do begin
    for x:=1 to 50 do begin
      read(byla,ch);
      mas[x,y]:=ch='1';     {  Skaitomi duomenys i˛ bylos ir }
      if mas[x,y] then      {  ie˛koma labiausiai nutolusi— juod— langeli—  }
        begin
          if x<cx then cx:=x;
          if x>w then w:=x;
          if y<cy then cy:=y;
          if y>h then h:=y
        end
    end;
    readln(byla)
  end;

  w:=(w-cx+1)div 2;  h:=(h-cy+1)div 2;   { Skai‡iuojamas plotis,auk˛tis }
  cx:=cx+w;  cy:=cy+h;                   {   ir centro koordinat‚s      }
  klaidos:=0;     { Pradinis klaid— skai‡ius }
  for x:=1 to w do
    for y:=1 to h do
      begin
        kamp[1]:=mas[cx-x,cy-y];        { Tikrinami 4 simetri˛ki langeliai }
        kamp[2]:=mas[cx-x,cy+y-1];
        kamp[3]:=mas[cx+x-1,cy+y-1];
        kamp[4]:=mas[cx+x-1,cy-y];
        b:=0;
        for a:=1 to 4 do
          if kamp[a] then b:=b+1;{ Skai‡iuojama,kiek simetrik— juod— langeli— }
        case b of
          2:klaidos:=klaidos+2;    { Jei tik 2 langeliai vienodi }
          1:begin                  { Jei 1 langelis nereikalingas }
             gerai:=false;
             klaidos:=klaidos+1;
             for a:=1 to 4 do
               if kamp[a] then c:=a
            end;
          3:begin                   {  Jei 1 langelio tr–ksta }
             gerai:=true;
             klaidos:=klaidos+1;
             for a:=1 to 4 do
               if not kamp[a] then c:=a
            end
         end;
         if (b=1) or (b=3) then   { Randamos blogo langelio koordinat‚s }
           case c of
            1:begin
               bx:=cx-x;
               by:=cy-y
              end;
            2:begin
               bx:=cx-x;
               by:=cy+y-1
              end;
            3:begin
               bx:=cx+x-1;
               by:=cy+y-1
              end;
            4:begin
               bx:=cx+x-1;
               by:=cy-y
              end
           end
      end;

    { Rezultato spausdinimas }
  if klaidos=0 then writeln('Perpie˛ta teisingai')
               else
    if klaidos>1 then writeln('Yra daugiau kaip viena klaida (',klaidos,')')
                 else
          if gerai then writeln('Reikia papildyti langeliu (',bx,',',by,')')
                   else writeln('Reikia pa˛alinti langel¨ (',bx,',',by,')');

  writeln;
  writeln(' Paspauskite Enter klavi˛…...');  { Pauz‚ }
  readln
end.