#include #include using namespace std; int checkTime(string time) { int hour = (time[0] - '0') * 10 + (time[1] - '0'); int minute = (time[3] - '0') * 10 + (time[4] - '0'); if (hour > 24 || minute > 60) { return 0; } if (time[3] == '0' && time[4] == '0') { return 1; } if (time[0] == time[3] && time[1] == time[4]) { return 1; } if (time[0] == time[4] && time[1] == time[3]) { return 1; } if (time[1] == time[0] + 1 && time[3] == time[1] + 1 && time[4] == time[3] + 1) { return 1; } if (time == "10:24" || time == "20:48") { return 1; } return 0; } int main() { int n; string time; cin >> n; for (int i = 0; i < n; ++i) { cin >> time; if (checkTime(time)) { cout << "YES" << endl; } else { cout << "NO" << endl; } } return 0; }