#include #include using namespace std; ifstream fin("date.in"); ofstream fout("date.out"); int n; char s[10]; int main() { cin >> n; while (n--) { cin >> s; int x = (s[0] - '0') * 10 + (s[1] - '0'); int y = (s[3] - '0') * 10 + (s[4] - '0'); if (x >= 24 || y >= 60) { cout << "NO\n"; continue; } if ((s[0] == s[3] && s[1] == s[4]) || (y == 0) || (s[0] == s[4] && s[1] == s[3]) || (s[0] == s[1] - 1 && s[1] == s[3] - 1 && s[3] == s[4] - 1)){ cout << "YES\n"; continue; } cout << "NO\n"; } return 0; }