#include #define pii pair #define pb push_back #define mp make_pair using namespace std; char x,y,z,t,c; int X,n,i,j; int main() { cin>>n; for(i=1;i<=n;i++) { cin>>x>>y>>c>>z>>t; x-='a'; y-='a'; z-='a'; t-='a'; if(z==0&&t==0) { cout<<"YES\n"; continue; } if(z==x&&t==y) { cout<<"YES\n"; continue; } if(t==x&&x==y) { cout<<"YES\n"; continue; } if(x+1==y&&y+1==z&&z+1==t) { cout<<"YES\n"; continue; } X=x*1000+y*100+z*10+t; for(j=1024;j<10000;j<<=1) if(j==X) { cout<<"YES\n"; continue; } cout<<"NO\n"; } return 0; }