#include <bits/stdc++.h>
using namespace std;
const int LEN = (int)2e5;
int q;
int n;
int a[LEN][2];
int dp[LEN][2][7];
bool solve(int i, int j, int k) {
  if ((k >= 3 && a[i][j] < 3) || (k < 3 && a[i][j] >= 3)) {
    dp[i][j][k] = 2;
  }
  if (dp[i][j][k]) {
    return dp[i][j][k] == 1;
  }
  if (j == 0) {
    if (k == 2) {
      dp[i][j][k] = 2 - (solve(i - 1, 0, 2) || solve(i - 1, 0, 3));
    } else if (k == 3) {
      dp[i][j][k] = 2 - solve(i, 1, 5);
    } else if (k == 4) {
      dp[i][j][k] = 2 - (solve(i - 1, 0, 2) || solve(i - 1, 0, 3));
    } else
      dp[i][j][k] = 2;
  } else {
    if (k == 2) {
      dp[i][j][k] = 2 - (solve(i - 1, 1, 2) || solve(i - 1, 1, 6));
    } else if (k == 5) {
      dp[i][j][k] = 2 - (solve(i - 1, 1, 2) || solve(i - 1, 1, 6));
    } else if (k == 6) {
      dp[i][j][k] = solve(i, 0, 4);
    } else
      dp[i][j][k] = 2;
  }
  return dp[i][j][k] == 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> q;
  while (q--) {
    cin >> n;
    for (int j = 0; j < 2; j++) {
      string s;
      cin >> s;
      for (int i = 0; i < n; i++) a[i][j] = s[i] - '0';
    }
    for (int i = 0; i < n; i++) memset(dp[i], 0, sizeof dp[i]);
    fill(dp[0][0], dp[0][0] + 6, 2);
    if (a[0][0] < 3) {
      dp[0][0][2] = 1;
    } else {
      dp[0][0][4] = 1;
    }
    cout << ((a[n - 1][1] < 3 && solve(n - 1, 1, 2)) ||
                     (a[n - 1][1] >= 3 && solve(n - 1, 1, 6))
                 ? "YES\n"
                 : "NO\n");
  }
  return 0;
}
