#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, tp = 0, r;
    cin >> n;
    int s[n][2];
    char s1[n + 2], s2[n + 2], a;
    for (int i = 0; i < n; i++) {
      s[i][0] = 0;
      cin >> a;
      if (a == '1' || a == '2')
        s1[i] = '1';
      else
        s1[i] = '2';
    }
    for (int i = 0; i < n; i++) {
      cin >> a;
      if (a == '1' || a == '2')
        s2[i] = '1';
      else
        s2[i] = '2';
    }
    r = 1;
    for (int i = 0; i < n; i++) {
      if (r == 1) {
        if (s1[i] == '1') continue;
        if (s1[i] == '2' && s2[i] == '1') {
          tp = 1;
          break;
        }
        if (s1[i] == '2' && s2[i] == '2') {
          r = 2;
        }
      } else {
        if (s2[i] == '1') continue;
        if (s2[i] == '2' && s1[i] == '1') {
          tp = 1;
          break;
        }
        if (s2[i] == '2' && s1[i] == '2') {
          r = 1;
        }
      }
    }
    if (tp == 1 || r == 1)
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
  return 0;
}
