var
  a: array [1..6] of longint;
  i,j,n:longint;
begin
  assign(input,'c.in');
  reset(input);
  assign(output,'c.out');
  rewrite(output);
  read(n);
  for i:=1 to n do begin
    for j:=1 to 6 do read(a[j]);
    if (a[1]=a[3]) or (a[1]=a[4]) or (a[1]=a[5]) or (a[1]=a[6]) then writeln('YES') else
    if (a[2]=a[3]) or (a[2]=a[4]) or (a[2]=a[5]) or (a[2]=a[6]) then writeln('YES') else
    if (a[3]=a[1]) or (a[3]=a[2]) or (a[3]=a[5]) or (a[3]=a[6]) then writeln('YES') else
    if (a[4]=a[1]) or (a[4]=a[2]) or (a[4]=a[5]) or (a[4]=a[6]) then writeln('YES') else
    if (a[5]=a[1]) or (a[5]=a[2]) or (a[5]=a[3]) or (a[5]=a[4]) then writeln('YES') else
    if (a[6]=a[1]) or (a[6]=a[2]) or (a[6]=a[3]) or (a[6]=a[4]) then writeln('YES') else writeln('NO');
  end;
  close(output);
end.
