uses
  SysUtils;

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

begin
  assign(input,'C.in');
  reset(input);
  readln(n);

  assign(output,'C.out');
  rewrite(output);
  for i:=1 to n do
   begin
    readln(a[1],a[2],a[3],a[4],a[5],a[6]);
    if (a[1]=a[3])or(a[1]=a[4])or(a[1]=a[6])or(a[1]=a[5])or
      (a[5]=a[2])or(a[5]=a[4])or(a[5]=a[3])or(a[2]=a[4])or
      (a[2]=a[3])or(a[2]=a[6])or(a[3]=a[6])or(a[4]=a[6])then writeln('YES')
        else writeln('NO');
    end;
  close(input);
  close(output);
end.
 
