program vtoraya;


{razmer matrici - 4x4}
const M = 3; {po X}
      N = 4; {po Y}

var
 matrix : array [1..N, 1..N] of real;

 p1_i, p1_j, p2_i, p2_j : integer; { pozicii iskomih elementov }
 i, j, k, l : integer; {peremennie dla ciklov}

  { peremennaya, neobhodimie dla raboti s faylami }
 f : text; {vhodnoy i vihodnoy fayl}




{
 *******************************************
 Osnovnaya procedura, delaet poisk v massive
 *******************************************
}
procedure Find;
begin

        { Poisk odinakovix elementov v matrix.
          Banal'no: poparno sravnivaem ih.    }

        for j:=1 to N do
           for i:=1 to M do
            begin

               for l:=1 to N do
                  for k:=1 to M do

                   {vnachale proverim, chtobi I ne ravnalos K, a J <> L}
                    if (i=k) and (j=l) then
                      {esli ravni, to nichego ne delaem}
                    else

                    if ( matrix[ i ][ j ] = matrix[ k ][ l ] ) then
                      begin
                      {Nawli sovpadauwie elementi}

                      {sohranaem pozicii elementov v peremennie}
                      p1_i := i;
                      p1_j := j;

                      p2_i := k;
                      p2_j := l;

                      EXIT;
                      {vihodim iz proceduri, ibo dalshe poisk ne imeet smisla}
                     end;

            end;



end;





{**********************************************************************}
{**********************************************************************}
{**********************************************************************}
BEGIN

{*********  Schityvanie iz fayla matrici in.txt  ***********}

assign (f, 'in.txt');
reset (f);   {Otkrivaem fayl dlya 4teniya 'f.txt'}

  {S4itivaem po stolbcu is fayla}
  for j:=1 to N do
  begin

      {a vnutri "s4itivania po stolbcu"
       s4itivaem ewe i kajdiy element v stroke,
       zanosya eti zna4enia iz fayla v matrix.
       Pri etom pomnim, chto v stroke u nas M elementov}
      for i:=1 to M do
      begin
        read(f, matrix[i][j]); {Schitivaem odno 4islo iz stroki fayla}
      end;

   readln(f); {Opuskaemsa vniz na stroku}
  end;

close (f);

writeln ('*****************************************');


{************  FIND ************}

{vizov proceduri find}
Find;


{********* Zapis resultata v fayl  ***********}
assign (f, 'out.txt');
rewrite (f); {Sozdaem noviy fayl}
writeln(f, 'Position 1 - X: ',p1_i, '   Position 1 - Y: ',p1_j);
writeln(f, 'Position 2 - X: ',p2_i, '   Position 2 - Y: ',p2_j);
close (f);


END.