#include <bits/stdc++.h>
using namespace std;
int main() {
  int tttt;
  cin >> tttt;
  string s1, s2;
  int n;
  bool f[200010][10];
  while (tttt--) {
    cin >> n;
    cin >> s1;
    cin >> s2;
    s1 = " " + s1;
    s2 = " " + s2;
    f[0][0] = 1;
    f[0][1] = 0;
    f[n][0] = f[n][1] = 0;
    for (int i = 1; i < (n + 1); i++) {
      f[i][0] = 0;
      f[i][1] = 0;
      int a1 = s1[i] - '0';
      int a2 = s2[i] - '0';
      if (f[i - 1][0] && a1 <= 2) f[i][0] = 1;
      if (f[i - 1][1] && a2 > 2 && a1 > 2) f[i][0] = 1;
      if (f[i - 1][0] && a1 > 2 && a2 > 2) f[i][1] = 1;
      if (f[i - 1][1] && a2 <= 2) f[i][1] = 1;
      if (f[i][0] + f[i][1] == 0) break;
    }
    if (f[n][1] == 1)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}
