#include using namespace std; int n , i , x , y , z , t , ora , Min; char xx[100] , yy[100] , zz[100] , tt[100] , r[100]; bool ok; bool putere2(int nr) { int t = nr - 1; if ( (nr & t) == 0) return true; return false; } int main() { //freopen("pelicular.in","r",stdin); //freopen("pelicular.out","w",stdout); cin >> n; for (i = 1; i <= n; ++i) cin >> xx[i] >> yy[i] >> r[i] >> zz[i] >> tt[i]; for (i = 1; i <= n; ++i) { x = xx[i] - '0'; y = yy[i] - '0'; z = zz[i] - '0'; t = tt[i] - '0'; ora = x * 10 + y; Min = z * 10 + t; ok = false; if (ora >= 0 && ora < 24 && Min >= 0 && Min < 60) { if (Min == 0) ok =true; if (ora == Min) ok = true; if (x == t && y == z) ok = true; if (y == x + 1 && z == y + 1 && t == z + 1) ok = true; if (x != 0 && putere2(ora * 100 + Min) == true) ok = true; } if (ok) cout << "YES\n"; else cout<<"NO\n"; } return 0; }