#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
  int t;
  cin >> t;
  while (t--) {
    int len;
    cin >> len;
    string s1, s2;
    cin >> s1 >> s2;
    int cnt1 = 0, cnt2 = 0;
    if (s1[0] > '2') {
      cnt1++;
      if (s2[0] <= '2') {
        puts("NO");
        continue;
      }
      cnt2++;
    }
    bool flag = true;
    for (int i = 1; i < s1.size(); ++i) {
      if (cnt1 % 2) {
        if (s2[i] > '2') {
          cnt2++;
          if (s1[i] <= '2') {
            flag = false;
            break;
          }
          cnt1++;
        }
      } else {
        if (s1[i] > '2') {
          cnt1++;
          if (s2[i] <= '2') {
            flag = false;
            break;
          }
          cnt2++;
        }
      }
    }
    if (cnt2 % 2 == 0) flag = false;
    if (flag) {
      puts("YES");
    } else {
      puts("NO");
    }
  }
}
