#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  string a, b;
  bool k = 0;
  bool ans = 1;
  int n;
  bool u = 0, d = 0;
  while (q--) {
    cin >> n;
    cin >> a >> b;
    for (int i = 0; i < n; i++) {
      u = (a[i] - '0' <= 2);
      d = (b[i] - '0' <= 2);
      if (!k) {
        if (u) {
          continue;
        } else {
          if (!d) {
            k = !k;
            continue;
          } else {
            ans = 0;
            break;
          }
        }
      } else {
        if (d) {
          continue;
        } else {
          if (!u) {
            k = !k;
            continue;
          } else {
            ans = 0;
            break;
          }
        }
      }
    }
    cout << (ans && k ? "YES" : "NO") << endl;
    k = 0;
    ans = 1;
  }
}
