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.io.*;
  public class Main {
      static Scanner in =new Scanner(System.in);
      static final Random random=new Random();
      static int mod=1000_000_007;
      static int []rank;
      static List<List<Integer>>adj;
      public static void main(String[] args) {
          int tt=in.nextInt();//in.nextLine();
             outer:while(tt-->0) {
                 int n=in.nextInt();in.nextLine();
                 char []c1=in.nextLine().toCharArray();
                 char []c2=in.nextLine().toCharArray();
                 for(int i=1;i<n-1;i++){
                     if(c1[i]=='1'&& c2[i]=='1'){
                         System.out.println("NO");
                         continue outer;
                     }
                 }
                 System.out.println("YES");
                 
         }
      }
  //     static int make_even(int []a){
  
  //     }
      static int sum(int n){
          if(n<=0)return 0;
          return (n*(n+1))/2;
      }
      static void uf (int[] root, int v1, int v2) {
              int rootP = find(v1,root);
              int rootQ = find(v2,root);
              if (rootP == rootQ) return;
              if (rank[rootQ] > rank[rootP]) {
                  root[rootP] = rootQ;
                  rank[rootQ]+=rank[rootP];
                  rank[rootP]=0;
              }
              else {
                  root[rootQ] = rootP;
                  rank[rootP]+=rank[rootQ];
                  rank[rootQ]=0;
              }
      }
      static int find(int p,int [] root) {
          	while (p != root[p]) {
                 root[p] =root[root[p]];
                  p = root[p];
              }
              return p;
          }
      static int nCr(int n,int r,int p){
          if (r == 0) return 1; 
          if(r==1)return n;
          return ((int)fact(n)*modInverse((int)fact(r),p)%p * modInverse((int)fact(n-r),p) % p)%p; 
      }
      static int modInverse(int n, int p){ 
          return power(n, p-2, p); 
      } 
      static int power(int x,int y,int p){ 
          int res = 1;
          x= x % p;
          while (y>0){
              if (y%2==1) 
                  res= (res*x)% p;
              y= y >> 1;
              x= (x*x)% p; 
          }
          return res; 
      } 
      static void seive(){
          int num=1000001;
          boolean[] prime = new boolean[num];
          Arrays.fill(prime,true);
          for (int i=2; i*i<=num; i++) {
              if(prime[i] == true) {
                  for(int j=i*i; j<num; j=j+i) {
                     prime[j]=false;
                  }
              }
          }
      }
      static long[]readAr(int n) {
          long[] a=new long[(int)n];
          for (int i=0; i<n; i++) {a[i]=in.nextLong();}
          return a;
  	}
      static int[]readA1r(int n) {
          int[] a=new int[(int)n];
          for (int i=0; i<n; i++) {a[i]=in.nextInt();}
          return a;
  	}
      static int fact(int k){
          long[]f=new long[10001];f[1]=1;
          for(int i=2;i<10001;i++){
              f[i]=(i*f[i-1]% mod);
          }
          return (int)f[k];
      }
  	static void ruffleSort(int[] a) {
  		int n=a.length;
  		for (int i=0; i<n; i++) {
  			int oi=random.nextInt(n), temp=a[oi];
  			a[oi]=a[i]; a[i]=temp;
  		}
  		Arrays.sort(a);
  	}
  	static void reverse(int []a){
          int n= a.length;
          for(int i=0;i<n/2;i++){
              int temp=a[i];
              a[i]=a[n-i-1];
              a[n-i-1]=temp;
          }
          //debug(a);
  	}
  	static void debug(int []a) {
          for (int i=0; i<a.length;i++) System.out.print(a[i]+" ");
          System.out.println();
  	}
  	static void print(List<Integer>s) {
          for(int x:s) System.out.print(x+",");
          System.out.println();
  	}
  	static long gcd(long a, long b) {
          return (b==0) ? a : gcd(b, a % b);
  	}
      static long find_max(long []a){
          long m=Integer.MIN_VALUE;
          for(long x:a)m=Math.max(x,m);
          return m;
      }
      static int find_min(int []a){
          int m=Integer.MAX_VALUE;
          for(int x:a)m=Math.min(x,m);
          return m;
      }
  }