#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int q;
  cin >> q;
  while (q--) {
    int n;
    string s[2];
    cin >> n >> s[0] >> s[1];
    int p = 0, q = 1, i;
    for (i = 0; i < n; i++) {
      if ((s[p][i] == '1') or (s[p][i] == '2')) continue;
      if ((s[q][i] == '1') or (s[q][i] == '2')) break;
      swap(p, q);
    }
    auto success = (i == n) and (p == 1);
    cout << (success ? "YES\n" : "NO\n");
  }
}
