#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
int t = 1;
cin >> t;
int tt = t;
while (t--) {
int n;
cin >> n;
string a, b;
cin >> a >> b;
int i = 0, j = 0;
bool flag = true;
while (i < n && j < n) {
if (a[i] == b[j]) i++, j++;
else if (a[i] != '.' && b[j] != '.') {
flag = false;
break;
} else if ((a[i] - '0') % 2 == 0) {
if (i < n - 1) swap(a[i], a[i + 1]);
else {
flag = false;
break;
}
} else if ((b[j] - '0') % 2 == 1) {
if (j < n - 1) swap(b[j], b[j + 1]);
else {
flag = false;
break;
}
} else {
flag = false;
break;
}
}
if (flag) cout << "YES";
else cout << "NO";
cout << endl;
}
return 0;
}
Copy