#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
int t;
cin >> t;
while (t--) {
string a, b;
int n;
cin >> n;
cin >> a >> b;
string A, B;
for (char &i : a) {
if (i != '.') A += i;
}
for (char &i : b) {
if (i != '.') B += i;
}
cout << (A == B ? "yes" : "no") << '\n';
}
return 0;
}