uses math;
var s,s1,s2:string;
    i,j,k,l,n,m,p1,p2,p,kk:integer;
    c,c1:char;
    t:real;
begin
readln(n);
for i:=1 to n do
  begin
  k:=0;
  readln(s);
  if ((s[1] in ['0'..'1']) and (s[2] in ['0'..'9']))
     or ((s[1]='2') and (s[2] in ['0'..'3'])) then
    if (s[4] in ['0'..'5']) and (s[5] in ['0'..'9']) then
    begin

  s1:=s[1]+s[2];
  s2:=s[4]+s[5];
  if s1=s2 then k:=1;
  if s2='00' then k:=1;
  if k=0 then
    begin
    s2:=s[5]+s[4];
    if s1=s2 then k:=1;
    end;
  if (k=0) and (s[1]<>'0') then
    begin
    s1:=s[1]+s[2]+s[4]+s[5];
    val(s1,p1,p);
    t:=log2(p1);
    if t-trunc(t)=0 then k:=1;
    end;
  if k=0 then
    begin
    kk:=1;
    c:=s[1];
    inc(c);
    if c<>s[2] then kk:=0;
    c:=s[2];
    inc(c);
    if c<>s[4] then kk:=0;
    c:=s[4];
    inc(c);
    if c<>s[5] then kk:=0;

    if kk=1 then k:=1;
    end;
  end;
  if k=1 then writeln('YES')
         else writeln('NO');
  end;
end.