#include <iostream> #include <limits.h> #include <cmath> #include <string> #include <stdio.h> #include <algorithm> #include <stdlib.h> #include <vector> #include <stack> #include <map> #include <fstream> using namespace std; int i,j,n,m; int v[10001]; int a,b,c,d; string s; int main(){ cin>>n; for(i=1; i<=n; i++) { bool ok = true; cin>>s; a=s[0]-'0'; b=s[1]-'0'; c=s[3]-'0'; d=s[4]-'0'; int xx = a; xx = xx*10 + b; int yy = c; yy = yy*10 + d; if ( xx > 24 or yy >= 60 and ok == true ) { ok = false; cout<<"NO"<<endl; } if ( xx == 24 and yy != 0 ok == true ) { ok = false; cout<<"NO"<<endl; } if ( c== 0 and d == 0 and ok == true ) { cout<<"YES"<<endl; ok = false;} if ( a<b and b<c and c<d and ok == true) { cout<<"YES"<<endl; ok = false;} if ( a == d and b == c and ok == true) { cout<<"YES"<<endl;; ok = false;} if ( a == c and b ==d and ok == true) { cout<<"YES"<<endl;; ok = false;} int x = a; x = x*10 + b; x = x*10 + c; x = x*10 + d; for(j=2; j<=x; j*=2) if (j==x and ok == true) { cout<<"YES"<<endl;; ok = false; } if (ok == true) cout<<"NO"<<endl; } return 0; }