program peculiar;
var n,i:byte; x,y,z,t:char; nr,er:integer; s:string; c:boolean;
begin
readln(n);
for i:=1 to n do begin
        readln(s); c:=false;
        x:=s[1]; y:=s[2]; z:=s[4]; t:=s[5];
        if (x in ['0'..'2']) and (z in ['0'..'6']) then begin

        if (z='0') and (t='0') then c:=true;
        if (x=z) and (y=t) then c:=true;
        if (x=t) and (y=z) then c:=true;
        if ord(x)+ord(t)=ord(y)+ord(z) then c:=true;
        delete(s,3,1); val(s,nr,er); if (nr=1024) or (nr=2048) then c:=true;
        end
        else c:=false;
        if c then writeln('YES') else writeln('NO');
        end;
end.