#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define endl '\n'
#define Endl '\n'
using namespace std;
const int N = 2e5 + 5;
int tc, n, m, a[N];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); // cout.tie(0);
cin >> tc;
while (tc--) {
string x, y;
cin >> n >> x >> y;
bool hasAns = true;
char lastChar = 'a';
for (int i = 0; i < n; i++) {
int minChar = min(x[i], y[i]);
int maxChar = max(x[i], y[i]);
if (minChar >= lastChar) {
lastChar = minChar;
} else if (maxChar >= lastChar) {
lastChar = maxChar;
} else {
hasAns = false;
break;
}
}
cout << (hasAns ? "Yes" : "No") << endl;
}
return 0;
}