#include #define pii pair #define pb push_back #define mp make_pair using namespace std; char xx,yy,zz,tt,cc; int x,y,z,t; int X,n,i,j; bool ok; int main() { cin>>n; for(i=1;i<=n;i++) { cin>>xx>>yy>>cc>>zz>>tt; xx-='0'; yy-='0'; zz-='0'; tt-='0'; x=int (xx); y=int (yy); z=int (zz); t=int (tt); if(x==2&&y>3) { cout<<"NO\n"; continue; } if(x>2) { cout<<"NO\n"; continue; } if(z>5) { cout<<"NO\n"; continue; } if(z==0&&t==0) { cout<<"YES\n"; continue; } if(z==x&&t==y) { cout<<"YES\n"; continue; } if(t==x&&z==y) { cout<<"YES\n"; continue; } if(x+1==y&&y+1==z&&z+1==t) { cout<<"YES\n"; continue; } X=x*1000+y*100+z*10+t; ok=1; if(X==2048||X==1024) cout<<"YES\n"; else cout<<"NO\n"; } return 0; }