#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n;
int a1[N];
int a2[N];
string tmp1, tmp2;
int dp[N][3];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    cin >> n;
    cin >> tmp1 >> tmp2;
    int f = 1;
    for (int i = 1; i <= n; i++)
      a1[i] = tmp1[i - 1] - '0', a2[i] = tmp2[i - 1] - '0';
    memset(dp, 0, sizeof(dp));
    dp[0][1] = 1;
    for (int i = 1; i <= n; i++) {
      if (dp[i - 1][1] == 1 && a1[i] <= 2) dp[i][1] = 1;
      if (dp[i - 1][2] == 1 && a2[i] <= 2) dp[i][2] = 1;
      if (dp[i - 1][1] == 1 && a1[i] >= 3 && a2[i] >= 3) dp[i][2] = 1;
      if (dp[i - 1][2] == 1 && a2[i] >= 3 && a1[i] >= 3) dp[i][1] = 1;
    }
    if (dp[n][2] == 1)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
