program ex;
type
ss=array[1..10,1..10]of integer;
var
hang,lie:ss;
n:integer;
procedure init;
var
i,j,xineger;
begin
assign(input,'island.in');
assign(output,'island.out');
reset(input);
rewrite(output);
readln(n);
for i:=1 to n do
begin
read(x);
j:=0;
while x<>0 do
begin
inc(j);
hang[i,j]:=x;
read(x);
end;
readln;
end;
for i:=1 to n do
begin
read(x);
j:=0;
while x<>0 do
begin
inc(j);
lie[i,j]:=x;
read(x);
end;
readln;
end;
close(input);
end;
begin
init;
wirteln('no');
close(output);
end.