#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int N=850;
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
#endif
ios_base::sync_with_stdio(0);
cin.tie(0);
int t;
cin>>t;
while(t--){
int n;
string s,a,x,y;
cin>>n;
cin>>s;
cin>>a;
for(int i=0;i<n;i++){
if(s[i]!='.')x+=s[i];
}
for(int i=0;i<n;i++){
if(a[i]!='.')y+=a[i];
}
cout<<(x==y?"yes":"no")<<'\n';
}
}