var n,i,j:byte;
a:array [1..6] of byte;

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]);
       if (a[1]=a[3]) or (a[1]=a[5]) or (a[1]=a[4]) or (a[1]=a[6]) or (a[2]=a[3]) or (a[2]=a[5]) or (a[2]=a[4]) or (a[2]=a[6]) or (a[3]=a[5]) or (a[3]=a[6]) or (a[4]=a[5]) or (a[4]=a[6]) then writeln('YES') else writeln('NO');

   end;
   close(output);
end.