const n=3;
type matrix=array [1..n,1..n] of integer;
var A,B:matrix;
k,l:integer;
t:boolean;


procedure enter (var C:matrix);
var i,j:integer;
begin
for i:=1 to n do begin
 for j:=1 to n do read(C[i,j]);
 readln;
 end;
end;

function three (var X,Y:matrix; n:integer):boolean;
 var k,l:integer;
 begin
for k:= 1 to n do begin
for l:= 1 to n do begin
if (X[k][l]<>Y[k][l]) then begin
three:=false;
break;
end;
end;
end;
end;

function compare (var D,E:matrix; n:integer):boolean;
var i,j,p,r:integer;
F,G,H:matrix;

begin
compare:=true;
for p:= 1 to n do begin
for r:= 1 to n do begin
G[p][r]:=D[r][p];
H[p][r]:=D[n-r+1][n-p+1];
end;
end;
for p:=1 to n do begin
for r:=1 to n do
F[p][r]:=H[r][p];
end;
if not three (G,E,n) then begin
if not three (H,E,n) then begin
if not three (F,E,n) then compare:=false
end;
end;
end;

begin
write ('enter A');
enter(A);
write ('enter B');
enter(B);
t:=compare(A,B,n);
write(t);
readln;
end.