#include <bits/stdc++.h>
using namespace std;
string s[2];
string ans[10000];
int main() {
  int q;
  cin >> q;
  for (int x = 0; x < q; x++) {
    int n;
    cin >> n;
    cin >> s[0];
    for (int y = 0; y < n; y++) {
      if (s[0][y] == '3' || s[0][y] == '4' || s[0][y] == '5' ||
          s[0][y] == '6') {
        s[0][y] = '1';
      } else {
        s[0][y] = '0';
      }
    }
    cin >> s[1];
    for (int y = 0; y < n; y++) {
      if (s[1][y] == '3' || s[1][y] == '4' || s[1][y] == '5' ||
          s[1][y] == '6') {
        s[1][y] = '1';
      } else {
        s[1][y] = '0';
      }
    }
    int z = 0;
    for (int y = 0; y < n; y++) {
      if (s[z][y] == '1') {
        z++;
        z = z % 2;
        if (s[z][y] == '1') {
          continue;
        }
        ans[x] = "NO";
        continue;
      }
    }
    if (z == 0) {
      ans[x] = "NO";
      continue;
    }
    if (ans[x] == "NO") {
      continue;
    }
    ans[x] = "YES";
  }
  for (int x = 0; x < q; x++) {
    cout << ans[x] << endl;
  }
}
