#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 200000 + 7;
int q;
int n;
int arr[2][MAX_N];
bool ans;
char c;
void go(int a, int b, int w) {
  if (a == 1 && b == n) {
    ans = 1;
    return;
  } else if (a == 0 && b == n) {
    ans = 0;
    return;
  } else if (w == 1) {
    if (arr[a][b] / 3 == 0) {
      ans = 0;
      return;
    } else {
      go(a, b + 1, 2);
    }
  } else if (w == 2) {
    if (arr[a][b] / 3 == 0) {
      go(a, b + 1, 2);
    } else {
      if (a == 1) {
        go(a - 1, b, 3);
      } else {
        go(a + 1, b, 1);
      }
    }
  } else {
    if (arr[a][b] / 3 == 0) {
      ans = 0;
      return;
    } else {
      go(a, b + 1, 2);
    }
  }
}
int main() {
  cin >> q;
  for (; q > 0; q--) {
    cin >> n;
    for (int i = 0; i < 2; i++) {
      for (int j = 0; j < n; j++) {
        cin >> c;
        arr[i][j] = c - '0';
      }
    }
    go(0, 0, 2);
    if (ans) {
      cout << "YES\n";
    } else {
      cout << "NO\n";
    }
    ans = 0;
  }
}
