#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 1;
void solve() {
string s;
string t;
int n;
cin >> n;
cin >> s >> t;
vector<int> p1, p2;
vector<int> pos1, pos2;
for (int i = 0 ; i < n ; i++) {
if (s[i] != '.') {
p1.push_back(s[i] - '0');
pos1.push_back(i);
}
if (t[i] != '.') {
p2.push_back(t[i] - '0');
pos2.push_back(i);
}
}
if (p1.size() != p2.size()) {
cout << "no" << endl;
return;
}
for (int i = 0 ; i < (int) p1.size() ; i++) {
if (p1[i] != p2[i]) {
cout << "no" << endl;
return;
}
if (p1[i] % 2 == 0 && pos1[i] > pos2[i]) {
cout << "no" << endl;
return;
}
if (p1[i] % 2 == 1 && pos1[i] < pos2[i]) {
cout << "no" << endl;
return;
}
}
cout << "yes" << endl;
}
int main() {
int t = 1;
cin >> t;
while (t--) {
solve();
}
return 0;
}
Copy