#include #include #include #include #include #include #include #include #include #include using namespace std; inline bool check(int h, int m) { if (h < 0 || h >= 24) { return 0; } if (m < 0 || m >= 60) { return 0; } int x = h * 100 + m; for (int i = 1; i < 10; ++i) { if (x == 1024 * i) { return 1; } } return m == 0 || h == m || h == (m % 10) * 10 + (m / 10) || (h % 10 == h / 10 + 1 && m / 10 == h % 10 + 1 && m % 10 == m / 10 + 1); } int main() { #ifndef ONLINE_JUDGE freopen("a.in", "r", stdin); freopen("a.out", "w", stdout); #endif int tests; scanf("%d\n", &tests); while (tests--) { int h, m; scanf("%d:%d\n", &h, &m); if (check(h, m)) { printf("YES\n"); } else { printf("NO\n"); } } return 0; }