#include<bits/stdc++.h>
using namespace std;
#define ll long long
void solve()
{
int n; cin >> n;
string a, b; cin >> a >> b;
string c;
c.push_back(min(a[0], b[0]));
for(int i = 1; i < n; i++){
if(a[i] >= c.back() && b[i] >= c.back()){
c.push_back(min(a[i], b[i]));
}
else if(a[i] >= c.back()){
c.push_back(a[i]);
}
else if(b[i] >= c.back()){
c.push_back(b[i]);
}
else{
cout << "No\n";
return;
}
}
cout << "Yes\n";
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int t; cin >> t;
while(t--){
solve();
}
}