{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  n,i,F,B,L,R,U,D:integer;
  z:boolean;
begin
  assign(input,'C.in'); reset(input);
  assign(output,'C.out'); rewrite(output);
  readln(n);
  for i:=1 to n do
  begin
    readln(f,b,l,r,u,d);
    z:=false;
    if (f=l) or (f=r) or (f=u) or (f=d) then
      z:=true;
    if (b=l) or (b=r) or (b=u) or (b=d) then
      z:=true;
    if (l=u) or (l=d) then
      z:=true;
    if (r=u) or (r=d) then
      z:=true;
    if z then
      writeln('YES')
    else
      writeln('NO');
  end;
  close(input);
  close(output);
end.
 