#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define no cout << "NO" << endl
#define yes cout << "YES" << endl
void solve() {
int n;
cin >> n;
string x, y;
cin >> x >> y;
if (n == 1) {
(x == y ? yes : no);
return;
}
for (int i = 0; i + 1 < n; ++i) {
if (y[i] == '0' && y[i + 1] == '0') {
bool ok = false;
if (i - 1 >= 0 && y[i - 1] == '1') ok = true;
if (i + 2 < n && y[i + 2] == '1') ok = true;
if (!ok) {
no;
return;
}
}
}
yes;
}
int32_t main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while (t--) solve();
}