#include #include #include using namespace std; bool IsValid(string &s) { if (s.size() != 5) return false; if (s.find(':') != 2) return false; stringstream ss(s); int h, m; char c; ss >> h; ss >> c; ss >> m; if (h <= 24 && m <= 60) return true; return false; } bool IsRound(string &s) { return s.substr(3) == "00"; } bool IsDoubled(string &s) { return s.substr(0, 2) == s.substr(3, 2); } bool IsMirror(string &s) { return (s[0] == s[4] && s[1] == s[3]); } bool IsConsecutive(string &s) { return s[4] == s[3] + 1 && s[3] == s[1] + 1 && s[1] == s[0] + 1; } bool IsPowerOfTwo(string &s) { return s == "10:24" || s == "20:48"; } int main() { int n; string s; cin >> n; for (int i = 0; i < n; i++) { cin >> s; if (!IsValid(s)) cout << "NO" << endl; else if (IsRound(s) || IsDoubled(s) || IsMirror(s) || IsConsecutive(s) || IsPowerOfTwo(s)) cout << "YES" << endl; else cout << "NO" << endl; } return 0; }