#include #include #include #include using namespace std; typedef long long LL; const int N = 1e3 + 10; char a[N], b[N]; int n; int check() { for(int i = 0; i < n; i ++) if(!( (a[i] == 'A' && b[i] == 'U') || (a[i] == 'T' && b[i] == 'A') || (a[i] == 'C' && b[i] == 'G') || (a[i] == 'G' && b[i] == 'C') )) return 0; return 1; } int main() { int T; scanf("%d", &T); while(T--) { scanf("%d", &n); scanf(" %s %s", a, b); puts(check() ? "YES" : "NO"); } return 0; }