#include #include #include #include #include #include #include #include #include #include using namespace std; int N; char sir[10]; int main() { //freopen ("input", "r", stdin); //freopen ("output", "w", stdout); scanf ("%d\n", &N); for (int i=1; i<=N; i++) { gets (sir + 1); int X = sir[1] - '0', Y = sir[2] - '0', Z = sir[4] - '0', T = sir[5] - '0'; if (X * 10 + Y >=24 || Z * 10 + T >= 60) { printf ("NO\n"); continue; } bool ok = 0; int n = X * 1000 + Y * 100 + Z * 10 + T; if ((n & (n-1)) == 0 && X != 0) ok = 1; if (X * 10 + Y == Z * 10 + T) ok = 1; if (X * 10 + Y == T * 10 + Z) ok = 1; if (Y == X + 1 && Z == Y + 1 && T == Z + 1) ok = 1; if (Z == 0 && T == 0) ok = 1; if (ok) printf ("YES\n"); else printf ("NO\n"); } return 0; }