program C;

{$APPTYPE CONSOLE}

var a:array [1..6] of longint;
i,j,n,k:longint;
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
      begin
          read(a[j]);
      end;
      k:=0;
      if (a[1]=a[3]) then k:=1;
      if (a[1]=a[4]) then k:=1;
      if (a[1]=a[5]) then k:=1;
      if (a[1]=a[6]) then k:=1;

      if a[2]=a[3] then k:=1;
      if a[2]=a[4] then k:=1;
      if a[2]=a[5] then k:=1;
      if a[2]=a[6] then k:=1;

      if a[4]=a[5] then k:=1;
      if a[5]=a[3] then k:=1;
      if a[3]=a[6] then k:=1;
      if a[6]=a[4] then k:=1;
      readln;
      if k=1 then writeln('YES') else writeln('NO');
      

   end;
   close(input);
   close(output);
end.
