#include <bits/stdc++.h>
using namespace std;
const long long base = 1e9 + 7;
const long long MAX_N = 1e6 + 1;
const long long MAX_M = 1e3 + 1;
long long dd[MAX_N];
long long leftt[2][MAX_N];
long long tren[2][MAX_N];
void Solves() {
  long long q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    string s;
    string t;
    cin >> s >> t;
    for (int i = 0; i <= n + 1; i++)
      leftt[0][i] = leftt[1][i] = tren[0][i] = tren[1][i] = 0;
    leftt[0][1] = 1;
    for (int i = 1; i <= n; i++) {
      if (s[i - 1] <= '2') {
        if (leftt[0][i] == 1) leftt[0][i + 1] = 1;
      } else {
        if (leftt[0][i] == 1) tren[1][i] = 1;
      }
      if (t[i - 1] <= '2') {
        if (leftt[1][i] == 1) leftt[1][i + 1] = 1;
      } else {
        if (tren[1][i] == 1) {
          leftt[1][i + 1] = 1;
        }
        if (leftt[1][i] == 1) {
          tren[0][i] = 1;
        }
      }
      if (s[i - 1] > '2') {
        if (tren[0][i] == 1) leftt[0][i + 1] = 1;
      }
    }
    if (leftt[1][n + 1] == 1)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
}
int main() { Solves(); }
