#include using namespace std; int main() { int n; cin>>n; while(cin.get()!='\n') ; for(int i=0;i>x>>y; cin.get(); cin>>z>>t; while(cin.get()!='\n') ; int xy=(x-'0')*10+(y-'0'),zt=(z-'0')*10+(t-'0'); bool pec=false; if( (z=='0' && t=='0') || ( x==z && y==t ) || ( x==t && y==z ) || ( y-x==1 && z-y==1 && t-z==1 ) || ( x!='0' && (((xy*100+zt)&(xy*100+zt-1))==0) ) ) pec=true; if(xy>24 || zt>60) pec=false; if(pec) cout<<"YES\n"; else cout<<"NO\n"; } return 0; }