#include <bits/stdc++.h>
using namespace std;
int n;
short a[2][200012];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int T;
  cin >> T;
  while (T--) {
    cin >> n;
    char c;
    bool down = 0, no = 0;
    for (int i = (1); i <= (n); ++i) cin >> c, a[0][i] = c - 48;
    for (int i = (1); i <= (n); ++i) cin >> c, a[1][i] = c - 48;
    for (int i = (1); i <= (n); ++i) {
      if (a[down][i] > 2 && a[down ^ 1][i] <= 2) {
        no = 1;
        break;
      }
      if (a[down][i] > 2) down ^= 1;
    }
    if (no == 1 || down == 0)
      cout << "NO\n";
    else
      cout << "YES\n";
  }
  return 0;
}
