#include <bits/stdc++.h>
using namespace std;
const int maxn = 2 * 1e5 + 4;
int main() {
  ios::sync_with_stdio(false);
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    char s[2][n + 1];
    cin >> s[0] >> s[1];
    int line = 0, flag = 0;
    for (int i = 0; i < n; i++) {
      int cnt = 0;
      while (s[line][i] >= '3') {
        cnt++;
        if (cnt & 1) line = 1 - line;
        if (!(cnt & 1)) i++;
        if (i >= n) break;
      }
      if (cnt & 1) {
        flag = 1;
        break;
      }
    }
    if (flag || line == 0)
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
  return 0;
}
