#include #include using namespace std; string s; int i,n,x,y,z,t; int main() { cin >> n; for (i=1;i<=n;i++) { cin >> s; x=(s[0]-'0')*10+s[1]-'0'; y=(s[3]-'0')*10+s[4]-'0'; if ((x>=24) || (y>=60)) { cout << "NO\n"; continue; } z=s[4]*10+s[3]; t=x*100+y; while ((t%2==0) && (t>0)) t/=2; if ((y==0) || (x==y) || (x==z) || ((t==1) && (s[0]!='0')) || ((x%10==x/10+1) && (y/10==x%10+1) && (y%10==y/10+1))) { cout << "YES\n"; } else cout << "NO\n"; } return 0; }