#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    string s1;
    string s2;
    bool flag = true;
    cin >> s1 >> s2;
    int count = 0;
    for (int i = 0; i < n; i++) {
      if (flag == true) {
        if (s1[i] - '0' <= 2) {
          count = count;
        } else {
          if (s2[i] - '0' >= 3) {
            count++;
            flag = false;
          } else {
            count = 0;
            break;
          }
        }
      } else {
        if (s2[i] - '0' <= 2) {
          count = count;
        } else {
          if (s1[i] - '0' >= 3) {
            count++;
            flag = true;
          } else {
            count = 0;
            break;
          }
        }
      }
    }
    if (count % 2 != 0) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
}
