#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define trace(x) cout << #x << ": " << x << endl
int32_t main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int t; cin >> t;
while(t--)
{
int n; cin >> n;
string s, t; cin >> s >> t;
int cnt1 = 0, cnt2 = 0;
for(int i = n-1; i >= 0; i--)
{
//cout << s[i] << ' ' << s[i - 1] << endl;
if(s[i] < s[i - 1]) cnt1++;
if(t[i] < t[i - 1]) cnt2++;
cnt1 += cnt1;
cnt2 += cnt2;
}
if(cnt1 <= cnt2) cout << "Yes" << endl;
else cout << "No" << endl;
}
return 0;
}