description: Monocarp is playing a computer game. Now he wants to complete the first level of this game.
  
  A level is a rectangular grid of 2 rows and n columns. Monocarp controls a character, which starts in cell (1, 1) — at the intersection of the 1-st row and the 1-st column.
  
  Monocarp's character can move from one cell to another in one step if the cells are adjacent by side and/or corner. Formally, it is possible to move from cell (x_1, y_1) to cell (x_2, y_2) in one step if |x_1 - x_2| ≤ 1 and |y_1 - y_2| ≤ 1. Obviously, it is prohibited to go outside the grid.
  
  There are traps in some cells. If Monocarp's character finds himself in such a cell, he dies, and the game ends.
  
  To complete a level, Monocarp's character should reach cell (2, n) — at the intersection of row 2 and column n.
  
  Help Monocarp determine if it is possible to complete the level.
  
  Input
  
  The first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. Then the test cases follow. Each test case consists of three lines.
  
  The first line contains a single integer n (3 ≤ n ≤ 100) — the number of columns.
  
  The next two lines describe the level. The i-th of these lines describes the i-th line of the level — the line consists of the characters '0' and '1'. The character '0' corresponds to a safe cell, the character '1' corresponds to a trap cell.
  
  Additional constraint on the input: cells (1, 1) and (2, n) are safe.
  
  Output
  
  For each test case, output YES if it is possible to complete the level, and NO otherwise.
  
  Example
  
  Input
  
  
  4
  3
  000
  000
  4
  0011
  1100
  4
  0111
  1110
  6
  010101
  101010
  
  
  Output
  
  
  YES
  YES
  NO
  YES
  
  Note
  
  Consider the example from the statement.
  
  In the first test case, one of the possible paths is (1, 1) → (2, 2) → (2, 3).
  
  In the second test case, one of the possible paths is (1, 1) → (1, 2) → (2, 3) → (2, 4).
  
  In the fourth test case, one of the possible paths is (1, 1) → (2, 2) → (1, 3) → (2, 4) → (1, 5) → (2, 6).
solution: 
  /*
                                        بسم الله الرحمن الرحيم
   
      /$$$$$  /$$$$$$  /$$    /$$  /$$$$$$                                                                  
     |__  $$ /$$__  $$ |$$    |$$ /$$__  $$                                                                 
            | $$| $$  \ $$|    $$|$$| $$  \ $$                                                                 
            | $$| $$$$$$$$|  $$ / $$/| $$$$$$$$                                                                 
  / $$  | $$| $$__  $$ \  $$ $$/ | $$__  $$                                                                 
  | $$  | $$| $$  | $$  \  $$$/  | $$  | $$                                                                 
  |  $$$$$$/| $$  | $$   \  $/   | $$  | $$                                                                 
   \______/ |__/  |__/    \_/    |__/  |__/    
   
  /$$$$$$$  /$$$$$$$   /$$$$$$   /$$$$$$  /$$$$$$$   /$$$$$$  /$$      /$$ /$$      /$$ /$$$$$$$$ /$$$$$$$ 
  | $$__  $$| $$__  $$ /$$__  $$ /$$__  $$| $$__  $$ /$$__  $$| $$$    /$$$| $$$    /$$$| $$_____/| $$__  $$
  | $$  \ $$| $$  \ $$| $$  \ $$| $$  \__/| $$  \ $$| $$  \ $$| $$$$  /$$$$| $$$$  /$$$$| $$      | $$  \ $$
  | $$$$$$$/| $$$$$$$/| $$  | $$| $$ /$$$$| $$$$$$$/| $$$$$$$$| $$ $$/$$ $$| $$ $$/$$ $$| $$$$$   | $$$$$$$/
  | $$____/ | $$__  $$| $$  | $$| $$|_  $$| $$__  $$| $$__  $$| $$  $$$| $$| $$  $$$| $$| $$__/   | $$__  $$
  | $$      | $$  \ $$| $$  | $$| $$  \ $$| $$  \ $$| $$  | $$| $$\  $ | $$| $$\  $ | $$| $$      | $$  \ $$
  | $$      | $$  | $$|  $$$$$$/|  $$$$$$/| $$  | $$| $$  | $$| $$ \/  | $$| $$ \/  | $$| $$$$$$$$| $$  | $$
  |__/      |__/  |__/ \______/  \______/ |__/  |__/|__/  |__/|__/     |__/|__/     |__/|________/|__/  |__/
                                                                                                                                                                                                                  
                                                                                                                                                                                                                  
   
  */
  
  import java.util.*;
  import java.lang.*;
  import java.io.*;
  
  public class CEdu115 {
      public static void main(String[] args) throws java.lang.Exception {
          // your code goes here
         // try {
              // Scanner sc=new Scanner(System.in);
              FastReader sc = new FastReader();
              int t = sc.nextInt();
              while (t-- > 0) {
                  int n=sc.nextInt();
                  int[][] arr=new int[2][n];
                  boolean[][] dp=new boolean[2][n];
                  for(int j=0;j<2;j++){
                      char[] s=sc.next().toCharArray();
                      for(int i=0;i<n;i++){
                          arr[j][i]=s[i]-'0';
                          dp[j][i]=false;
                      } 
                  }
                  dp[1][n-1]=true;
                  if(arr[0][n-1]==0){
                      dp[0][n-1]=true;
                  }
                  if(arr[1][n-2]==0){
                      dp[1][n-2]=true;
                  }
                  if((dp[1][n-2] || dp[0][n-1] || dp[1][n-1]) && (arr[0][n-2]==0)){
                      dp[0][n-2]=true;
                  }
                  for(int j=n-3;j>=0;j--){
                      for(int i=1;i>=0;i--){
                          if(arr[i][j]==1){
                              dp[i][j]=false;
                              continue;
                          }
                          if(i==1){
                              if(arr[i][j]==0 && (dp[i-1][j] || dp[i][j+1] || dp[i-1][j+1])){
                                  dp[i][j]=true;
                              }
                          }
                          else if(i==0){
                              if(arr[i][j]==0 && (dp[i][j+1] || dp[i+1][j] || dp[i+1][j+1])){
                                  dp[i][j]=true;
                              }
                          }
                      }
                  }
                  /*for(int i=0;i<2;i++){
                      for(int j=0;j<n;j++){
                          System.out.print(arr[i][j]+" ");
                      }
                      System.out.println();
                  }
                  for(int i=0;i<2;i++){
                      for(int j=0;j<n;j++){
                          System.out.print(dp[i][j]+" ");
                      }
                      System.out.println();
                  }*/
                  if(dp[0][0])System.out.println("YES");
                  else System.out.println("NO");
              }
         /* } catch (Exception e) {
              return;
          }*/
  
      }
      public static int lowerbound(long[] ar,int k)
  {
      int s=0;
      int e=ar.length;
      while (s !=e)
      {
          int mid = s+e>>1;
          if (ar[mid] <k)
          {
              s=mid+1;
          }
          else
          {
              e=mid;
          }
      }
      if(s==ar.length)
      {
          return -1;
      }
      return s;
  }
  
      public static class pair {
          int ff;
          int ss;
  
          pair(int ff, int ss) {
              this.ff = ff;
              this.ss = ss;
          }
      }
  
      static int BS(int[] arr, int l, int r, int element) {
          int low = l;
          int high = r;
          while (high - low > 1) {
              int mid = low + (high - low) / 2;
              if (arr[mid] < element) {
                  low = mid + 1;
              } else {
                  high = mid;
              }
          }
          if (arr[low] == element) {
              return low;
          } else if (arr[high] == element) {
              return high;
          }
          return -1;
      }
  
      static int lower_bound(int[] arr, int l, int r, int element) {
          int low = l;
          int high = r;
          while (high - low > 1) {
              int mid = low + (high - low) / 2;
              if (arr[mid] < element) {
                  low = mid + 1;
              } else {
                  high = mid;
              }
          }
          if (arr[low] >= element) {
              return low;
          } else if (arr[high] >= element) {
              return high;
          }
          return -1;
      }
  
      static int upper_bound(int[] arr, int l, int r, int element) {
          int low = l;
          int high = r;
          while (high - low > 1) {
              int mid = low + (high - low) / 2;
              if (arr[mid] <= element) {
                  low = mid + 1;
              } else {
                  high = mid;
              }
          }
          if (arr[low] > element) {
              return low;
          } else if (arr[high] > element) {
              return high;
          }
          return -1;
      }
  
      public static int upperbound(long[] arr, int k) {
          int s = 0;
          int e = arr.length;
          while (s != e) {
              int mid = s + e >> 1;
              if (arr[mid] <= k) {
                  s = mid + 1;
              } else {
                  e = mid;
              }
          }
          if (s == arr.length) {
              return -1;
          }
          return s;
      }
      public static long pow(long x,long y,long mod){
          if(x==0)return 0l;
          if(y==0)return 1l;
          //(x^y)%mod
          if(y%2l==1l){
              return ((x%mod)*(pow(x,y-1l,mod)%mod))%mod;
          }
          return pow(((x%mod)*(x%mod))%mod,y/2l,mod);
      }
  
      public static long gcd_long(long a, long b) {
          // a/b,a-> dividant b-> divisor
          if (b == 0)
              return a;
          return gcd_long(b, a % b);
      }
  
      public static int gcd_int(int a, int b) {
          // a/b,a-> dividant b-> divisor
          if (b == 0)
              return a;
          return gcd_int(b, a % b);
      }
  
      public static int lcm(int a, int b) {
          int gcd = gcd_int(a, b);
          return (a * b) / gcd;
      }
  
      static class FastReader {
          BufferedReader br;
          StringTokenizer st;
  
          public FastReader() {
              br = new BufferedReader(new InputStreamReader(System.in));
          }
  
          String next() {
              while (st == null || !st.hasMoreElements()) {
                  try {
                      st = new StringTokenizer(br.readLine());
                  } catch (IOException e) {
                      e.printStackTrace();
                  }
              }
              return st.nextToken();
          }
  
          int nextInt() {
              return Integer.parseInt(next());
          }
  
          String nextLine() {
              String s = "";
              try {
                  s = br.readLine();
              } catch (IOException e) {
                  e.printStackTrace();
              }
              return s;
          }
  
          Long nextLong() {
              return Long.parseLong(next());
          }
      }
  }
  
  /*
   * public static boolean lie(int n,int m,int k){ if(n==1 && m==1 && k==0){
   * return true; } if(n<1 || m<1 || k<0){ return false; } boolean
   * tc=lie(n-1,m,k-m); boolean lc=lie(n,m-1,k-n); if(tc || lc){ return true; }
   * return false; }
   */
  