#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long q;
  cin >> q;
  while (q--) {
    long long n;
    cin >> n;
    string a[2];
    cin >> a[0] >> a[1];
    for (long long i = 0; i < n; i++) {
      if (a[0][i] == '1' or a[0][i] == '2')
        a[0][i] = '1';
      else
        a[0][i] = '3';
      if (a[1][i] == '1' or a[1][i] == '2')
        a[1][i] = '1';
      else
        a[1][i] = '3';
    }
    bool dp[n + 5][2];
    memset(dp, false, sizeof(dp));
    if (a[0][0] == '1') dp[0][0] = true;
    if (a[0][0] == '3' and a[1][0] == '3') {
      dp[0][1] = true;
    }
    for (long long i = 1; i < n; i++) {
      if (a[0][i] == '1' and dp[i - 1][0] == true) dp[i][0] = true;
      if (a[1][i] == '1' and dp[i - 1][1] == true) dp[i][1] = true;
      if (a[0][i] == '3' and a[1][i] == '3' and dp[i - 1][0] == true) {
        dp[i][1] = true;
      }
      if (a[1][i] == '3' and a[0][i] == '3' and dp[i - 1][1] == true) {
        dp[i][0] = true;
      }
    }
    if (dp[n - 1][1])
      cout << "YES\n";
    else
      cout << "NO\n";
  }
}
