#include #include #include using namespace std; bool poweroftwo(int i) { int k=1; while (k <= i) { if (k == i) return true; k*=2; } return false; } int main() { int n; cin >> n; for (int i = 0; i < n; i++) { char s[10]; cin >> s; int hours,minutes; char *h,*m; h = strtok(s, ":"); m = strtok(NULL, ":"); hours = atoi(h); minutes = atoi(m); if (minutes == 0) cout << "YES"; else if (hours == minutes) cout << "YES"; else if (hours%10 == minutes/10 && hours/10 == minutes%10) cout << "YES"; else if (hours%10 == hours/10 + 1 && hours%10 + 1 == minutes/10 && minutes%10 == minutes/10+1) cout << "YES"; else if (poweroftwo(hours*100 + minutes)) cout << "YES"; else cout << "NO"; } return 0; }