#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define all(v) v.begin(), v.end()
#define pb push_back
#define sz(x) (int)(x).size()
const int N = 3e5 + 5;
void solve() {
int n;
string a, b;
cin >> n >> a >> b;
vector<vi> ga(15), gb(15);
vector<char> aa, bb;
for(int i = 0; i < n; ++i){
if(isdigit(a[i]))
ga[a[i] - '0'].pb(i), aa.pb(a[i]);
if(isdigit(b[i]))
gb[b[i] - '0'].pb(i), bb.pb(b[i]);
}
if(aa == bb){
bool ok = 1;
for(int nn = 0; nn <= 9; ++nn){
for(int i = 0; i < sz(gb[nn]); ++i){
if(nn & 1)
ok &= (gb[nn][i] <= ga[nn][i]);
else
ok &= (gb[nn][i] >= ga[nn][i]);
}
}
if(ok)
cout << "yes";
else
// puts("no");
cout << "no";
}else {
// puts("no");
cout << "no";
}
}
int main() {
cin.tie(0)->sync_with_stdio(0);
int t = 1;
cin >> t;
// scanf("%d",&t);
while(t--)
solve(), cout << '\n';
}
Copy