program Main;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  filein,fileout : textfile;
  N,c : integer;
  kub : array [1..6] of integer;

procedure write_result;
begin
  if    (kub[1] = kub [3])
    or  (kub[1] = kub [4])
    or  (kub[1] = kub [5])
    or  (kub[1] = kub [6])
    or  (kub[2] = kub [3])
    or  (kub[2] = kub [4])
    or  (kub[2] = kub [5])
    or  (kub[2] = kub [6])
    or  (kub[3] = kub [5])
    or  (kub[3] = kub [6])
    or  (kub[4] = kub [5])
    or  (kub[4] = kub [6])
      then
        begin
        writeln(fileout,'YES');
        exit;
        end;
writeln(fileout,'NO');
end;

begin
  assignfile(filein,'C.in');
  reset(filein);
  readln(filein,N);

  assignfile(fileout,'C.out');
  rewrite(fileout);

  for c:=1 to N do
    begin
      read(filein,kub[1]);
      read(filein,kub[2]);
      read(filein,kub[3]);
      read(filein,kub[4]);
      read(filein,kub[5]);
      read(filein,kub[6]);
      write_result;
    end;

  close(filein);
  close(fileout);
end.
 