var k:array[1..6] of integer;
n,i,j,u:integer;
begin
assign(input,'c.in');
reset(input);
assign(output,'c.out');
rewrite(output);
readln(input,n);
for j:=1 to n do begin
for i:=1 to 6 do
read(input,k[i]);
readln(input);
              i:=1;
 while  (i<6)     do
  begin if (k[i]= k[i+2]) then u:=1;
 i:=i+1;           end;
 if ((k[3]=k[6]) or (k[1]=k[6]) or (k[2]=k[3]) or (k[4]=k[5]) or (k[1]=k[5]) or (k[1]=k[4]) or (k[2]=k[6]) or (k[2]=k[5]))
 then u:=1;
 if u=1 then writeln(output,'Yes') else writeln(output,'No');
 u:=0;

end;
close(output);
end.

