#include #include #include #include using namespace std; int n; int valid(int,int); int main() { cin>>n; while(n) { int zt=0;int xy=0; cin>>xy; cin.get(); cin>>zt; if(valid(xy,zt)) cout<<"YES"; else cout<<"NO"; cout<<"\n"; n--; } return 0; } int valid(int xy,int zt) { if(xy>=24&& xy<0) return 0; if(zt>=60 && zt<0) return 0; int x=xy/10; int y=xy%10; int z=zt/10; int t=zt%10; if(z==0&&t==0) return 1; if(xy==zt) return 1; if(x==t&&y==z) return 1; if(y==x+1 && z==x+2 && t==x+3 ) return 1; int aux=xy*10+zt; int nu=1; while(aux) { if(aux%2==1) {nu=0;aux=0;} aux/=10; } if(nu) return 1; return 0; }