#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define all(v) v.begin(),v.end()
#define FIO \
ios_base::sync_with_stdio(false);\
cin.tie(NULL);\
cout.tie(NULL);
void solve()
{
ll n; cin >> n;
string s,t; cin >> s >> t;
string s1 = s;
s = "A" + s;
t = "A" + t;
bool check1 = false, check2 = false;
for(ll i = 1; i <= n; i++)
{
char c1 = s[i], c2 = t[i];
if(c1 >= s[i - 1] && c2 >= s[i - 1])
{
s[i] = min(c1,c2);
}
else if(c1 >= s[i - 1])
{
s[i] = c1;
}
else if(c2 >= s[i - 1])
{
s[i] = c2;
}
else
{
check1 = true;
break;
}
}
for(ll i = 1; i <= n; i++)
{
char c1 = t[i], c2 = s1[i];
if(c1 >= t[i - 1] && c2 >= t[i - 1])
{
t[i] = min(c1,c2);
}
else if(c1 >= t[i - 1])
{
t[i] = c1;
}
else if(c2 >= t[i - 1])
{
t[i] = c2;
}
else
{
check2 = true;
break;
}
}
cout << (check1 && check2 ? "No" : "Yes") << "\n";
}
int32_t main()
{
ll t=1;
cin>>t;
for(ll i=1;i<=t;i++)
{
// cout<<"Case "<<i<<": ";
solve();
}
}