const c:array[1..12,1..2] of byte=((1,4),(1,5),(1,6),(1,3),(2,4),(2,6),(2,3),(2,5),(3,5),(3,6),(4,5),(4,6));
var a:array[1..6] of longint;
    i,j,n,k:longint;
    s:string;
Begin
assign(input,'C.in');reset(input);
assign(output,'C.out');rewrite(output);
readln(n);
for i:=1 to n do
begin
     for j:=1 to 6 do read(a[j]);
     s:='NO';
     for k:=1 to 12 do if (a[c[k][1]]=a[c[k][2]]) then s:='YES';
     writeln(s);readln;
end;
close(input);close(output);
end.