#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  char a[n + 1][2];
  for (int i = 0; i < n; i++) cin >> a[i][0];
  for (int i = 0; i < n; i++) cin >> a[i][1];
  for (int i = 0; i < n; i++) {
    a[i][0] -= '0';
    a[i][1] -= '0';
    if (a[i][0] == 1) a[i][0] = 2;
    if (a[i][1] == 1) a[i][1] = 2;
  }
  a[n][0] = 2;
  a[n][1] = 2;
  int pos = 0;
  for (int i = 0; i <= n; i++) {
    if (a[i][pos] == 2) {
    } else if (a[i][pos ^ 1] != 2) {
      pos ^= 1;
    } else {
      cout << "NO" << endl;
      return;
    }
  }
  cout << (pos ? "YES" : "NO") << "\n";
}
int main() {
  int q;
  cin >> q;
  while (q--) solve();
}
