#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    char str[2][n + 1];
    cin >> str[0];
    cin >> str[1];
    long long s_r = 1, s_c = 1;
    while (1) {
      if (str[(s_r - 1) % 2][s_c - 1] == '1' ||
          str[(s_r - 1) % 2][s_c - 1] == '2') {
        s_c += 1;
      } else {
        if (str[(s_r) % 2][s_c - 1] == '1' || str[(s_r) % 2][s_c - 1] == '2') {
          break;
        } else {
          s_r += 1;
          s_c += 1;
        }
      }
      if (s_c == n + 1) {
        break;
      }
    }
    if (s_c == n + 1 && s_r % 2 == 0) {
      cout << "YES" << '\n';
    } else {
      cout << "NO" << '\n';
    }
  }
}
