#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string s, s1;
    cin >> s >> s1;
    int flag = 0;
    int dir = 0;
    for (int i = 0; i < n; i++) {
      if (s[i] - '0' <= 2) {
        s[i] = '0';
      } else {
        s[i] = '1';
      }
      if (s1[i] - '0' <= 2) {
        s1[i] = '0';
      } else {
        s1[i] = '1';
      }
    }
    int i;
    for (i = 0; i < n; i++) {
      if (dir == 0) {
        if (s[i] == '0') {
          continue;
        } else if (s[i] == '1' && s1[i] == '1') {
          dir = 1;
        } else
          break;
      } else {
        if (s1[i] == '0') {
          continue;
        } else if (s[i] == '1' && s1[i] == '1') {
          dir = 0;
        } else
          break;
      }
    }
    if (dir == 1 && i == n) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}
