#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define mp make_pair #define pb push_back #define ff first #define ss second #define int64 unsigned long long bool db(string x){ if(x[0] == x[3] && x[1] == x[4]) return 1; return 0; } bool consec(string x){ if(x[0] == x[1] - 1 && x[1] == x[3] - 1 && x[3] == x[4] - 1) return 1; return 0; } bool palin(string x){ if(x[0] == x[4] && x[1] == x[3]) return 1; return 0; } bool power(string x){ if(x[0] == '0') return 0; int a = x[0] - '0'; a = a * 10 + (x[1] - '0'); a = a * 10 + (x[3] - '0'); a = a * 10 + (x[4] - '0'); if(a == 1024 || a == 2048 || a == 4096 || a == 8192) return 1; return 0; } int main(){ ios_base::sync_with_stdio(false); int n; cin >> n; while(n--){ string s; cin >> s; if(consec(s) || power(s) || palin(s) || db(s)) cout << "YES\n"; else cout << "NO\n"; } }