#include using namespace std; bool validation(char x, char y, char z){ int xi, yi, zi, ti; xi=x-'0'; yi=y-'0'; zi=z-'0'; if(xi>2)return 0; if(xi==2 && yi>=4)return 0; if(zi>5)return 0; return 1; } bool poweOfTwo(char x, char y, char z, char t){ int xi, yi, zi, ti; xi=x-'0'; yi=y-'0'; zi=z-'0'; ti=t-'0'; if(xi==0)return 0; int number = xi*1000 + yi*100 + zi*10 + ti; while (number%2==0 && number>1){ number/=2; } if(number==1)return 1; return 0; } int main() { char z,t, x,y, doubleDot; int n; cin>>n; for(int i=1; i<=n; ++i){ cin>>x>>y>>doubleDot>>z>>t; if(!validation(x,y,z))cout<<"NO"<<'\n'; else{ if(x==z && y==t)cout<<"YES"<<'\n'; else if(z=='0' && t=='0')cout<<"YES"<<'\n'; else if(x==t && z==y)cout<<"YES"<<'\n'; else if(x==y-1 && y==z-1 && z==t-1)cout<<"YES"<<'\n'; else if(poweOfTwo(x, y,z,t))cout<<"YES"<<'\n'; else cout<<"NO"<<'\n'; } } return 0; }