program Problem_C;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  i: Integer;
  j: Integer;
  n: Integer;
  k: Integer;
  l: Integer;
  tf: Boolean;
  a: Array [1..6] of Integer;
begin
  Assign(input, 'C.in');
  Reset(input);
  Assign(output, 'C.out');
  ReWrite(output);
  Read(input, n);
  for i := 1 to n do
  begin
    for j := 1 to 6 do
      Read(input, a[j]);
    tf := False;
    for j := 1 to 6 do
    begin
      for k := 1 to 6 do
        if a[j] = a[k] then
          if j <> k then
            if j mod 2 = 0 then
            begin
              if k <> j - 1 then
              begin
                tf := True;
                break;
              end;
            end
            else
              if k <> j + 1 then
              begin
                tf := True;
                break;
              end;
      if tf then
        break;
    end;
    if tf then
      Writeln(output, 'YES')
    else
      Writeln(output, 'NO');
  end;
  Close(output);
  Close(input);
end.
 