#include int cas,n,m,l,t,p; char a[1000],b[1000]; int main(){ scanf("%d",&cas); while (cas-->0){ scanf("%d",&n); scanf("%s",a); scanf("%s",b); p=0; for (int i=1;i<=n;i++){ if (a[i]=='A') if (b[i]!='U') p=1; if (a[i]=='C') if (b[i]!='G') p=1; if (a[i]=='G') if (b[i]!='C') p=1; if (a[i]=='T') if (b[i]!='A') p=1; } if (p==1) printf("NO\n"); else printf("YES\n"); } }