var
   n,i,j,k,d,z : longint;
   a : array [1..10000] of integer;
begin
   assign(input,'c.in');   reset(input);
   assign(output,'c.out'); rewrite(output);

   read(n);

   for i:=1 to n do
    begin
      for j:=1 to 6 do
       read(a[j]);
      z:=0;
      for k:=1 to 5 do
       begin
        for d:=k+2 to 6 do
         if z=1 then break
         else
          if a[k]=a[d] then
           begin
            writeln('YES');
            z:=1;
            break;
           end;
       end;
      if z=0  then writeln('NO');
     end;
    close(input); close(output);
end.