#include <bits/stdc++.h>
using namespace std;
const int sz = 1e5 + 100;
int n;
string s[2];
int main() {
  ios_base::sync_with_stdio(false);
  int t;
  for (cin >> t; t--;) {
    cin >> n >> s[0] >> s[1];
    int x = 0;
    bool ans = 1;
    for (int i = 0; i < n; i++) {
      if (s[x][i] <= '2') continue;
      if (s[(x + 1) % 2][i] <= '2') ans = 0;
      x = (x + 1) % 2;
    }
    if (!ans || !x)
      cout << "NO\n";
    else
      cout << "YES\n";
  }
}
