const   filein='C.in';
        fileout='C.out';

var i,j,k,l,m,n         :longint;
    a                   :array[1..6] of integer;
    b                   :array[1..10] of boolean; 

procedure readf;
begin
 assign(input,filein);
 reset(input);
  read(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[4]) or (a[1]=a[5]) or (a[1]=a[6]) or
      (a[2]=a[3]) or (a[2]=a[4]) or (a[2]=a[5]) 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
    b[i]:=true
   else
    b[i]:=false;
  end;
 close(input);
end;

procedure vivod;
begin
 assign(output,fileout);
 rewrite(output);
  for i:=1 to n do
   if b[i]=true then
    writeln('YES')
   else
    writeln('NO');
 close(output);
end;

begin
 readf;
 vivod;
end. 
