#include using namespace std; int n,i,a; char x,y,z,t,o; int main() { cin>>n; cin.get(); for(i=1; i<=n; ++i) { cin.get(x); cin.get(y); cin.get(o); cin.get(z); cin.get(t); cin.get(); if((x-'0')<=2 && (z-'0')<=6) { if(x-'0'==2) { if(y-'0'<=4) { if(z-'0'==6) { if(t-'0'==0) { if(z=='0' && t=='0') cout<<"YES\n"; else { if(x==z && y==t) cout<<"YES\n"; else { if(x==t && y==z) cout<<"YES\n"; else { if((int)(x+1)==(int)y && (int)(y+1)==(int)z && (int)(z+1)==(int)t) cout<<"YES\n"; else { a=(x-'0')*1000+(y-'0')*100+(z-'0')*10+(t-'0'); if(a!=1) { while(a%2==0) a=a/2; if(a==1) cout<<"YES\n"; else cout<<"NO\n"; } else cout<<"NO\n"; } } } } } else cout<<"NO/n"; } else { if(z=='0' && t=='0') cout<<"YES\n"; else { if(x==z && y==t) cout<<"YES\n"; else { if(x==t && y==z) cout<<"YES\n"; else { if((int)(x+1)==(int)y && (int)(y+1)==(int)z && (int)(z+1)==(int)t) cout<<"YES\n"; else { a=(x-'0')*1000+(y-'0')*100+(z-'0')*10+(t-'0'); if(a!=1) { while(a%2==0) a=a/2; if(a==1) cout<<"YES\n"; else cout<<"NO\n"; } else cout<<"NO\n"; } } } } } } else cout<<"NO\n"; } else { if(z-'0'==6) { if(t-'0'==0) { if(z=='0' && t=='0') cout<<"YES\n"; else { if(x==z && y==t) cout<<"YES\n"; else { if(x==t && y==z) cout<<"YES\n"; else { if((int)(x+1)==(int)y && (int)(y+1)==(int)z && (int)(z+1)==(int)t) cout<<"YES\n"; else { a=(x-'0')*1000+(y-'0')*100+(z-'0')*10+(t-'0'); if(a!=1) { while(a%2==0) a=a/2; if(a==1) cout<<"YES\n"; else cout<<"NO\n"; } else cout<<"NO\n"; } } } } } else cout<<"NO\n"; } else { if(z=='0' && t=='0') cout<<"YES\n"; else { if(x==z && y==t) cout<<"YES\n"; else { if(x==t && y==z) cout<<"YES\n"; else { if((int)(x+1)==(int)y && (int)(y+1)==(int)z && (int)(z+1)==(int)t) cout<<"YES\n"; else { a=(x-'0')*1000+(y-'0')*100+(z-'0')*10+(t-'0'); if(a!=1) { while(a%2==0) a=a/2; if(a==1) cout<<"YES\n"; else cout<<"NO\n"; } else cout<<"NO\n"; } } } } } } } else cout<<"NO\n"; } return 0; }