#include <iostream> #include <cstring> using namespace std; int main() { int n,i,xy,zt,a1,a2,a3,a4,t,tz; char a[50][5]; cin>>n; for(i=1;i<=n;i++){ cin>>a[i]; cin.get(); } for(i=1;i<=n;i++){ xy=(a[i][0]-'0')*10+(a[i][1]-'0'); zt=(a[i][3]-'0')*10+(a[i][4]-'0'); tz=(a[i][4]-'0')*10+(a[i][3]-'0'); t=xy*100+zt; a1=a[i][0]-'0'; a2=a[i][1]-'0'; a3=a[i][3]-'0'; a4=a[i][4]-'0'; if(xy>=0 and xy<24 and zt>=0 and zt<60){ if(zt==0) cout<<"YES"<<endl; else{ if(xy==zt) cout<<"YES"<<endl; else{ if(xy==tz) cout<<"YES"<<endl; else{ if(a1==a2-1 and a1==a3-2 and a1==a4-3) cout<<"YES"<<endl; else{ if(t==1024 or t==2048 or t==4096 or t==8192) cout<<"YES"<<endl; else cout<<"NO"<<endl; } } } } } else cout<<"NO"<<endl; } return 0; }