{$APPTYPE CONSOLE}
program problem_c;
const
      filein  = 'c.in';
      fileout = 'c.out';
var
      i,j,k,l,m,n,p1,p2,p3,p4,p5,p6   : longint;

begin
  reset(input,filein); rewrite(output,fileout);
    read(n);
      for i:=1 to n do
        begin
          read(p1,p2,p3,p4,p5,p6);
          k:=0;
          if (p1=p3)or(p1=p4)or(p1=p5)or(p1=p6) then k:=1;
          if (p2=p3)or(p2=p4)or(p2=p5)or(p2=p6) then k:=1;

          if (p3=p1)or(p3=p2)or(p3=p5)or(p3=p6) then k:=1;
          if (p4=p1)or(p4=p2)or(p4=p5)or(p4=p6) then k:=1;
          
          if (p5=p1)or(p5=p2)or(p5=p3)or(p5=p4) then k:=1;
          if (p6=p1)or(p6=p2)or(p6=p3)or(p6=p4) then k:=1;
          if k=1 then writeln('YES') else writeln('NO');
        end;
end.
