#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string s1;
    string s2;
    cin >> s1;
    cin >> s2;
    int total = 0;
    int flag = 0;
    for (int i = 0; i < n; i++) {
      if (total % 2 == 0) {
        if (s1[i] - '0' == 3 || s1[i] - '0' == 4 || s1[i] - '0' == 5 ||
            s1[i] - '0' == 6) {
          if (s2[i] - '0' == 3 || s2[i] - '0' == 4 || s2[i] - '0' == 5 ||
              s2[i] - '0' == 6) {
            total++;
          } else {
            flag = 1;
            break;
          }
        }
      } else if (total % 2 != 0) {
        if (s2[i] - '0' == 3 || s2[i] - '0' == 4 || s2[i] - '0' == 5 ||
            s2[i] - '0' == 6) {
          if (s1[i] - '0' == 3 || s1[i] - '0' == 4 || s1[i] - '0' == 5 ||
              s1[i] - '0' == 6) {
            total++;
          } else {
            flag = 1;
            break;
          }
        }
      }
    }
    if (flag == 0 && total % 2 != 0) {
      cout << "YES"
           << "\n";
    } else {
      cout << "NO"
           << "\n";
    }
  }
}
