#include <bits/stdc++.h>
using namespace std;
int n;
int dp[4][200005];
string s[2];
bool f(int i, int j, int w) {
  if (i == 2 && j == n - 1) {
    if (w == 1) {
      if (s[i - 1][j] == '1' || s[i - 1][j] == '2') {
        return dp[i][j] = true;
      } else {
        return dp[i][j] = false;
      }
    } else if (w == 2) {
      if (s[i - 1][j] != '1' && s[i - 1][j] != '2') {
        return dp[i][j] = true;
      } else
        return dp[i][j] = false;
    }
    return dp[i][j] = false;
  }
  if (i >= 3 || i < 1 || j >= n) {
    return dp[i][j] = false;
  }
  if (dp[i][j] != -1) {
    return dp[i][j];
  }
  bool ret = false;
  if (w == 1) {
    if (s[i - 1][j] == '1' || s[i - 1][j] == '2') {
      ret = max(ret, f(i, j + 1, 1));
    } else {
      ret = max(ret, f(i - 1, j, 3));
      ret = max(ret, f(i + 1, j, 2));
    }
  } else if (w == 2) {
    if (s[i - 1][j] != '1' && s[i - 1][j] != '2') {
      ret = max(ret, f(i, j + 1, 1));
    }
  } else if (w == 3) {
    if (s[i - 1][j] != '1' && s[i - 1][j] != '2') {
      ret = max(ret, f(i, j + 1, 1));
    }
  }
  return dp[i][j] = ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  int q;
  cin >> q;
  while (q--) {
    memset(dp, -1, sizeof dp);
    cin >> n;
    cin >> s[0] >> s[1];
    bool r = f(1, 0, 1);
    if (r == true)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
