var  n,i,a1,a2,a3,a4,a5,a6:longint;


function check:string;
var i:integer;
begin
          if (a1=a3)or(a1=a4)or(a1=a5)or(a1=a6) then
          begin
               check:='YES';
               exit;
          end;
          if (a2=a3)or(a2=a4)or(a2=a5)or(a2=a6) then
          begin
               check:='YES';
               exit;
          end;
          if (a3=a1)or(a3=a2)or(a3=a5)or(a3=a6) then
          begin
               check:='YES';
               exit;
          end;
          if (a4=a1)or(a4=a2)or(a4=a5)or(a4=a6) then
          begin
               check:='YES';
               exit;
          end;
          if (a5=a1)or(a5=a2)or(a5=a3)or(a5=a4) then
          begin
               check:='YES';
               exit;
          end;
          if (a6=a1)or(a6=a2)or(a6=a3)or(a6=a4) then
          begin
               check:='YES';
               exit;
          end;
          check:='NO';
end;

begin
    assign(input,'c.in');
    reset(input);
    assign(output,'c.out');
    rewrite(output);
    readln(n);
    for i:=1 to n do
    begin
      readln(a1,a2,a3,a4,a5,a6);
      writeln(check);
    end;
    close(input);
    close(output);
end.
