#include "bits/stdc++.h"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
void solve(){
int n;
cin>>n;
string a,b;
cin>>a;
cin>>b;
string aa = "",bb="";
for (int i = 0; i < n; ++i)
{
if(a[i] != '.')
aa+=a[i];
if(b[i] != '.')
bb+=b[i];
}
cout<<(aa == bb ? "yes\n":"no\n");
}
int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("out.txt", "w",stdout);
#endif
FAST;
int t = 1;
cin>>t;
while(t--)
solve();
}