#include #include using namespace std; int n, x, y, z, t; string q; int main() { cin >> n; while ( n-- ) { cin >> q; x = q[0] - '0'; y = q[1] - '0'; z = q[3] - '0'; t = q[4] - '0'; if ( (!z && !t) || (x == z && y == t) || (x == t && y == z) || (y == x + 1 && z == y + 1 && t == z + 1) ) cout << "YES\n"; else { x = x * 1000 + y * 100 + z * 10 + t; if ( x == (1 << 10) || x == (1 << 11) || x == (1 << 12) || x == (1 << 13) ) cout << "YES\n"; else cout << "NO\n"; } } return 0; }