#include using namespace std; int main() { char dp; int i, n, ora, minut, x, y, z, t; cin >> n; for(i = 0; i < n; i++) { cin >> ora >> dp >> minut; x = ora / 10; y = ora % 10; z = minut / 10; t = minut % 10; if(!(ora >= 0 && ora < 24 && minut >= 0 && minut < 60)) { cout << "NO" << endl; // continue; ?? } else if((z == 0 && t == 0) || (x == z && y == t) || (x == t && y == z) || ((x - y) == -1 && (y - z) == -1 && (z - t) == -1) || (ora == 10 && minut == 24) || (ora == 20 && minut == 48)) { cout << "YES" << endl; // continue; ?? } else cout << "NO" << endl; } return 0; }