program ornamentas;
  type lapas = 1..50;
       ornam = array [ lapas,lapas ] of '0'..'1';
  var orn : ornam;
      ss  : text;
      x,y : lapas;
  procedure centras ( var x,y :lapas );
  { Randa ornamento centr… }
    var prx,pry,glx,gly, { Pirm— ir paskutini— juod— langeli— koordinat‚s }
        k,l : 0..50;
  begin
    prx := 0 ; pry := 0 ;
    glx := 0 ; gly := 0 ;
    for k := 1 to 50 do
      for l := 1 to 50 do
        if orn [ l,k ] = '1'
           then begin
                  if prx = 0 then prx := k;
                  if glx < l then glx:= k;
                  if pry = 0 then pry := l ;
                  if gly < l then gly:= l
                end;
    x := ( prx + glx ) div 2 ;  { Centro           }
    y := ( pry + gly ) div 2    { koordinat‚s      }
  end;
  procedure tikrinti ;
  { Tikrina,ar n‚ra klaid—, ir ,jei j— yra, parodo pranežim… }
    var i,j,a,b,a1,b1 : 0..50 ; { ­vairios koordinat‚s       }
        r : string[4];
        daug,           { Parodo , ar ne per daug klaid— }
        p : boolean ;   { Parodo , ar reikia pažalinti ar prid‚ti langel }
        m,n : integer ;
  begin
    daug := false ;
    p:=false ;
    i := 0; j := 0;
    for b := 1 to y do
       for a := 1 to x do
         if not daug
            then begin
                   b1 := y*2+1-b ;   { Tolimiausio tažko   }
                   a1 := x*2+1-a ;   { koordinat‚s (a1;b1) }
                   r := orn [ a,b ] + orn [ a1,b ] + orn [ a,b1 ] +
                        orn [ a1,b1 ] ;{ Langeliai,simetrižki lageliui (a;b) }
                   val (r,m,n);
                   case m of
                     1110 : if i = 0
                               then begin p := true ; i := a1 ; j := b1  end
                               else daug := true;
                     1101 : if i = 0
                               then begin p := true ; i := a ; j := b1  end
                               else daug := true;
                     1011 : if i = 0
                               then begin p := true ; i := a1 ; j := b  end
                               else daug := true;
                     0111 : if i = 0
                               then begin p := true ; i := a ; j := b  end
                               else daug := true;
                     0001 : if i = 0
                               then begin p := false ; i := a1 ; j := b1  end
                               else daug := true;
                     0010 : if i = 0
                               then begin p := false ; i := a ; j := b1  end
                               else daug := true;
                     0100 : if i = 0
                               then begin p := false ; i := a1 ; j := b  end
                               else daug := true;
                     1000 : if i = 0
                               then begin p := false ; i := a ; j := b  end
                               else daug := true;
                     1111,
                     0000 : ; { Tvarka ! }
                     else daug := true
                   end
                 end;
    if (i=0) and not daug
           then writeln ('Perpiežta teisingai')
           else if daug
                   then writeln ('Yra daugiau kaip viena klaida')
                   else if p then writeln ('Reikia papildyti langeliu (',
                                            i,',',j,')')
                             else writeln ('Reikia pažalinti langelõ (',
                                            i,',',j,')')
  end;
begin
  assign ( ss,'ORNAM.dat' );
  reset ( ss );
  for y := 1 to 50 do
    begin
      for x := 1 to 50 do
        read ( ss,orn[x,y] );
      readln ( ss )
    end;
  close ( ss );
  centras ( x,y );
  tikrinti
end.