#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef pair pii; typedef unsigned long long ull; typedef long long ll; typedef vector vi; #define xx first #define yy second #define rep(i, a, n) for (int i = a; i < n; i++) #define sa(n) scanf("%d", &(n)) #define vep(c) for(decltype((c).begin()) it = (c).begin(); it != (c).end(); it++) const int mod = int(1e9) + 7, INF = 0x3fffffff, maxn = 1e5 + 12; int n, m; int main(void) { int T; cin >> T; for (int cas = 1; cas <= T; cas++) { cin >> n; string a, b; cin >> a >> b; bool ok = true; for (int i = 0; i < a.size(); i++) { if (a[i] == 'A' && b[i] != 'U') ok = false; if (a[i] == 'T' && b[i] != 'A') ok = false; if (a[i] == 'C' && b[i] != 'G') ok = false; if (a[i] == 'C' && b[i] != 'G') ok = false; if (!ok) break; } if (ok) cout << "YES" << endl; else cout << "NO" << endl; } return 0; }