#include using namespace std; int T,x,y1; char a,b,c,d,w; int main () { //freopen("input","r",stdin); //freopen("output","w",stdout); scanf("%d\n",&T); while(T) { T--; scanf("%c%c%c%c%c\n",&a,&b,&w,&c,&d); a-=48; b-=48; c-=48; d-=48; x=a*10+b; y1=c*10+d; a=x/10; b=x%10; c=y1/10; d=y1%10; if(y1==0)printf("YES\n"); else if(x==y1)printf("YES\n"); else if(x==d*10+c)printf("YES\n"); else if(a==b-1&&b==c-1&&c==d-1)printf("YES\n"); else if(x*100+y1>999&&(x*100+y1==1024||x*100+y1==2048||x*100+y1==4096||x*100+y1==8192))printf("YES\n"); else printf("NO\n"); } return 0; }