#include #include using namespace std; bool put2(int a, int b) { int x = a * 100 + b; int xx = x; int cif = 0; do { cif++; xx /= 10; } while(xx); if( cif != 4 ) return false; while(x % 2 == 0) x /= 2; if( x == 1 ) return true; return false; } bool cons( char SIR[] ) { if( SIR[0] + 1 == SIR[1] && SIR[1] + 1 == SIR[3] && SIR[3] + 1 == SIR[4]) return true; return false; } char SIR[6]; int main() { int n; cin >> n; int a = 0, b = 0; cin.get(); for( int i = 1; i <= n; ++i ) { cin.getline(SIR, 6); a = 0, b = 0; a += (SIR[0] - '0') * 10; a += SIR[1] - '0'; b += (SIR[3] - '0') * 10; b += SIR[4] - '0'; if( a > 24 || b > 60 ) { cout << "NO" << '\n'; continue; } if( SIR[3] == '0' && SIR[4] == '0' ) { cout << "YES" << '\n'; continue; } if( a == b ) { cout << "YES" << '\n'; continue; } if( SIR[0] == SIR[4] && SIR[1] == SIR[3] ) { cout << "YES" << '\n'; continue; } if( put2(a, b) ) { cout << "YES" << '\n'; continue; } if( cons(SIR) ) { cout << "YES" << '\n'; continue; } cout << "NO" << '\n'; } return 0; }