#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10;
char s[3][N];
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 1; i <= 2; i++)
      for (int j = 1; j <= n; j++) {
        cin >> s[i][j];
        if (s[i][j] == '1' || s[i][j] == '2')
          s[i][j] = '1';
        else
          s[i][j] = '2';
      }
    int flag = 0, x = 1, y = 1;
    for (int i = 1; i <= n; i++) {
      if (s[y][i] == '1') {
        x++;
      } else if (s[y][i] == '2') {
        if (y == 1 && s[y + 1][i] == '2') {
          y++;
          x++;
        } else if (y == 2 && s[y - 1][i] == '2') {
          y--;
          x++;
        } else {
          flag = 1;
          break;
        }
      }
    }
    if (flag)
      cout << "NO" << endl;
    else if (x == n + 1 && y == 2)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
