program zadc;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  n,s:integer;
  i,a,b,c,d,e,f:integer;
begin
  assignfile(input,'input.txt');
  reset(input);
  assignfile(output,'output.txt');
  rewrite(output);
  read(n);
  for i:=1 to n do
    begin
      s:=1;
      read(a,b,c,d,e,f);
      if a=c then s:=s+1;
      if a=d then s:=s+1;
      if a=e then s:=s+1;
      if a=f then s:=s+1;
      if s>=2 then writeln('YES')
        else
          begin
            s:=1;
            if b=c then s:=s+1;
            if b=d then s:=s+1;
            if b=e then s:=s+1;
            if b=f then s:=s+1;
            if s>=2 then writeln('YES')
              else
                begin
                  s:=1;
                  if c=a then s:=s+1;
                  if c=b then s:=s+1;
                  if c=e then s:=s+1;
                  if c=f then s:=s+1;
                  if s>=2 then writeln('YES')
                    else
                      begin
                        s:=1;
                        if d=a then s:=s+1;
                        if d=b then s:=s+1;
                        if d=e then s:=s+1;
                        if d=f then s:=s+1;
                        if s>=2 then writeln('YES')
                          else
                            begin
                              s:=1;
                              if e=a then s:=s+1;
                              if e=b then s:=s+1;
                              if e=c then s:=s+1;
                              if e=d then s:=s+1;
                              if s>=2 then writeln('YES')
                                else
                                  begin
                                    s:=1;
                                    if f=a then s:=s+1;
                                    if f=b then s:=s+1;
                                    if f=c then s:=s+1;
                                    if f=d then s:=s+1;
                                    if s>=2 then writeln('YES') else writeln('NO');
                                  end;

                            end   ;

                      end;
                end              ;

          end                     ;



    end;
  closefile(output);
end.
