#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
string second[2];
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int q;
  cin >> q;
  int n;
  char c;
  while (q--) {
    cin >> n >> second[0] >> second[1];
    int i = 0, j = 0;
    for (i = 0; i < n; i++) {
      if (second[j][i] >= '3') {
        if (second[1 - j][i] < '3') {
          break;
        } else {
          j = 1 - j;
        }
      }
    }
    if (i == n && j == 1) {
      cout << "YES"
           << "\n";
    } else {
      cout << "NO"
           << "\n";
    }
  }
  return 0;
}
