program main;

{$APPTYPE CONSOLE}

uses
  SysUtils;

label 1;
var
n,ss,raz,t,f,j,i,sum:integer;
s2: array [1..50] of string;
tt: array [1..5] of string;
t3:boolean;
k,t2:integer;
t1,max,s1,s3: array [1..100] of integer;
g:integer;
begin

assignfile(input,'C.in');

reset (input);
raz:=0;
t:=0;
readln (input,s2[1]);
n:=strtoint(s2[1]);
For i:=2 to n do
readln (input, s2[i]);
close (input);

for i:=2 to n+1 do
begin
  t:=t+1;
  for j:= 0 to length(s2[i])-1 do
  if (s2[i,j]<>' ') then
   begin
   s1[t]:=strtoint(inttostr(s1[t])+s2[i,j]);
   end
  else
  INC(T);
 end;




for k:=0 to n-1 do
begin
  t3:=false;
 for i:=k*6+1 to k*6+6 do

   begin
    if i>2 then if s1[i]=s1[i-2] then t3:=true;

    if (i=k*6+6) then
    begin
     if t3=false then
       begin
       inc(t2);
      tt[t2]:='NO'
       end
     else
    begin
    inc(t2);
    tt[t2]:='YES'
    end;
    end;
  end;
  end;
 assignfile (output,'C.out');
rewrite (output);

for i:=1 to n do
writeln (output,tt[i]);
close(output);

  { TODO -oUser -cConsole Main : Insert code here }
end.
