#include <bits/stdc++.h>
typedef long long ll;
#define InAHurry cin.tie(0)->sync_with_stdio(0);
using namespace std;
int main(){
InAHurry;
int t;
cin>>t;
while(t--) {
int n;
cin>>n;
string a,b;
cin>>a>>b;
vector<int> va,vb;
for(auto i=0;i<n;i++) {
if(isdigit(a[i])) va.push_back(a[i]);
if(isdigit(b[i])) vb.push_back(b[i]);
}
if( va == vb ) cout<<"yes\n";
else
cout<<"no\n";
}
return 0;
}