#include <bits/stdc++.h>
using namespace std;
int MOD = 1000000007;
void init() {}
void solve() {
  int n;
  cin >> n;
  string pipeGrid[2];
  cin >> pipeGrid[0];
  cin >> pipeGrid[1];
  int numberOfRowChanges = 0;
  int rowNumber = 0;
  for (int i = 0; i < n; i++) {
    if (pipeGrid[rowNumber][i] == '3' || pipeGrid[rowNumber][i] == '4' ||
        pipeGrid[rowNumber][i] == '5' || pipeGrid[rowNumber][i] == '6') {
      int nextRowNumber = (rowNumber + 1) % 2;
      if (pipeGrid[nextRowNumber][i] == '3' ||
          pipeGrid[nextRowNumber][i] == '4' ||
          pipeGrid[nextRowNumber][i] == '5' ||
          pipeGrid[nextRowNumber][i] == '6') {
        numberOfRowChanges++;
        rowNumber = nextRowNumber;
      } else {
        cout << "NO\n";
        return;
      }
    }
  }
  if (numberOfRowChanges % 2 == 0) {
    cout << "NO\n";
  } else {
    cout << "YES\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  init();
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
