#include using namespace std; int main() { int z,n,t,x; cin>>z for(int i=1;i<=z;i++){ cin>>n; f.get(); cin>>t; if( z <= 24 && t<=60 ){ x = t%10*10+t/10; if(t == 0) cout<<"YES\n"; else if(n == t) cout<<"YES\n"; else if(n == x) cout<<"YES\n"; else cout<<"NO\n"; } else{ cout<<"NO\n"; } } return 0; }