#include using namespace std; int main() { int n, test, h, m, y, z, ok, nr, p; string time, XY, ZT, mirror; cin>>n; for(int i=0;i>time; ok=0; XY=time.substr(0, 2); ZT=time.substr(3, 2); h=time[3]-'0'; m=time[4]-'0'; y=time[0]-'0'; z=time[1]-'0'; nr=1000*y+100*z+10*h+m; if (ok==0 && ZT == "00" && (XY == "12" || XY == "11" || XY == "10" || XY == "09" || XY == "08" || XY == "07" || XY == "06" || XY == "05" || XY == "04" || XY == "03" || XY == "02" || XY == "01" || XY == "00")){ cout<<"YES"; ok=1; } if (ok==0 && XY==ZT && XY!="00") { ok=1; cout<<"YES";} if (ok==0 && z==h && y==m && h!=0 && m!=0) {cout<< "YES"; ok=1;} if (ok==0 && y==(z+1)==(h+2)==(m+3)) {cout<<"YES";ok=1;} if(ok==0){ p=1024; while (p<10000 && ok==0){ if(nr==p) {cout<<"YES";ok=1;} p=p*2; } } if(ok==0) cout<<"NO"<