description: n players are playing a game. 
  
  There are two different maps in the game. For each player, we know his strength on each map. When two players fight on a specific map, the player with higher strength on that map always wins. No two players have the same strength on the same map. 
  
  You are the game master and want to organize a tournament. There will be a total of n-1 battles. While there is more than one player in the tournament, choose any map and any two remaining players to fight on it. The player who loses will be eliminated from the tournament. 
  
  In the end, exactly one player will remain, and he is declared the winner of the tournament. For each player determine if he can win the tournament.
  
  Input
  
  The first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. The description of test cases follows.
  
  The first line of each test case contains a single integer n (1 ≤ n ≤ 10^5) — the number of players.
  
  The second line of each test case contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9, a_i ≠ a_j for i ≠ j), where a_i is the strength of the i-th player on the first map. 
  
  The third line of each test case contains n integers b_1, b_2, ..., b_n (1 ≤ b_i ≤ 10^9, b_i ≠ b_j for i ≠ j), where b_i is the strength of the i-th player on the second map. 
  
  It is guaranteed that the sum of n over all test cases does not exceed 10^5.
  
  Output
  
  For each test case print a string of length n. i-th character should be "1" if the i-th player can win the tournament, or "0" otherwise.
  
  Example
  
  Input
  
  
  3
  4
  1 2 3 4
  1 2 3 4
  4
  11 12 20 21
  44 22 11 30
  1
  1000000000
  1000000000
  
  
  Output
  
  
  0001
  1111
  1
  
  Note
  
  In the first test case, the 4-th player will beat any other player on any game, so he will definitely win the tournament.
  
  In the second test case, everyone can be a winner. 
  
  In the third test case, there is only one player. Clearly, he will win the tournament.
solution: import java.util.*;
  import java.io.*;
  
  ////***************************************************************************
   /* public class E_Gardener_and_Tree implements Runnable{
  
         public static void main(String[] args) throws Exception {
          new Thread(null, new E_Gardener_and_Tree(), "E_Gardener_and_Tree", 1<<28).start();
         }
      public void run(){
           WRITE YOUR CODE HERE!!!!
           JUST WRITE EVERYTHING HERE WHICH YOU WRITE IN MAIN!!!
         }
  
    }
  */
  /////**************************************************************************
  
  
  public class C_Game_Master{
      public static void main(String[] args) {
          FastScanner s= new FastScanner();
          //PrintWriter out=new PrintWriter(System.out);
          //end of program
          //out.println(answer);
          //out.close();
          StringBuilder res = new StringBuilder();
          int t=s.nextInt();
          int p=0;
          while(p<t){
          int n=s.nextInt();
          long array1[]= new long[n];
          yoyo obj5 = new yoyo();
          PriorityQueue<pair> nice1 = new PriorityQueue<pair>(obj5);
          long array2[]= new long[n];
          PriorityQueue<pair> nice2 = new PriorityQueue<pair>(obj5);
          for(int i=0;i<n;i++){
              array1[i]=s.nextLong();
              pair obj2 = new pair(array1[i],i);
              nice1.add(obj2);
          }
          for(int i=0;i<n;i++){
              array2[i]=s.nextLong();
              pair obj2 = new pair(array2[i],i);
              nice2.add(obj2);
          }
          ArrayList<pair> well1 = new  ArrayList<pair>(n+4);
          long array3[]= new long[n];
          ArrayList<pair> well2 = new  ArrayList<pair>(n+4);
          long array4[]= new long[n];
          for(int i=0;i<n;i++){
              pair obj= nice1.poll();
              well1.add(obj);
              array3[(int)obj.b]=i;
          }
  
          for(int i=0;i<n;i++){
              pair obj= nice2.poll();
              well2.add(obj);
              array4[(int)obj.b]=i;
          }
          long yes[]= new long[n];
          solve(well1,array3,well2,array4,yes,n);
          long yes1[]= new long[n];
          solve(well2,array4,well1,array3,yes1,n);
          for(int i=0;i<n;i++){
              long hh=(yes[i]|yes1[i]);
              res.append(hh);
          }
          res.append(" \n");
          p++;
      }
      System.out.println(res);
  
          
  
  
      }
      private static void solve(ArrayList<pair> well1, long[] array3, ArrayList<pair> well2,
              long[] array4, long[] yes, int n) {
  
                  Queue<Long> nice = new LinkedList<Long>();
                  long visited1[]= new long[n];
                  long visited2[]= new long[n];
                  nice.add(well1.get(n-1).b);
                  int check=1;
                  while(!nice.isEmpty()){
                      Queue<Long> nice2 = new LinkedList<Long>();
                      if(check==1){
                          // i have well1 ke numbers
                          while(!nice.isEmpty()){
                              long num=nice.poll();
                              yes[(int)num]=1;
                              long index=array4[(int)num];
                              visited2[(int)(index)]=1;
                              for(long j=index+1;j<n;j++){
                                  if(visited2[(int)j]==1){
                                      break;
                                  }
                                  pair obj3 = well2.get((int)j);
                                  nice2.add(obj3.b);
                                  visited2[(int)j]=1;
                              }
  
  
  
                          }
                          check=0;
                      }
                      else{
                           ///
                           while(!nice.isEmpty()){
                              long num=nice.poll();
                              yes[(int)num]=1;
                              long index=array3[(int)num];
                              visited1[(int)(index)]=1;
                              for(long j=index+1;j<n;j++){
                                  if(visited1[(int)j]==1){
                                      break;
                                  }
                                  pair obj3 = well1.get((int)j);
                                  nice2.add(obj3.b);
                                  visited1[(int)j]=1;
                              }
  
  
  
                          }
                          check=1;
  
                           ///
                      }
                      nice=nice2;
                  }
      }
      static class FastScanner {
  		BufferedReader br;
  		StringTokenizer st;
   
  		public FastScanner(String s) {
  			try {
  				br = new BufferedReader(new FileReader(s));
  			} catch (FileNotFoundException e) {
  				// TODO Auto-generated catch block
  				e.printStackTrace();
  			}
  		}
   
  		public FastScanner() {
  			br = new BufferedReader(new InputStreamReader(System.in));
  		}
   
  		String nextToken() {
  			while (st == null || !st.hasMoreElements()) {
  				try {
  					st = new StringTokenizer(br.readLine());
  				} catch (IOException e) {
  					// TODO Auto-generated catch block
  					e.printStackTrace();
  				}
  			}
  			return st.nextToken();
  		}
   
  		int nextInt() {
  			return Integer.parseInt(nextToken());
  		}
   
  		long nextLong() {
  			return Long.parseLong(nextToken());
  		}
   
  		double nextDouble() {
  			return Double.parseDouble(nextToken());
  		}
  	}
  
  
      static long modpower(long x, long y, long p)
       {
        long res = 1; // Initialize result
     
        x = x % p; // Update x if it is more than or
        // equal to p
     
        if (x == 0)
          return 0; // In case x is divisible by p;
     
        while (y > 0)
        {
     
          // If y is odd, multiply x with result
          if ((y & 1) != 0)
            res = (res * x) % p;
     
          // y must be even now
          y = y >> 1; // y = y/2
          x = (x * x) % p;
        }
        return res;
      }
  
    
     // SIMPLE POWER FUNCTION=>
  
  
        static long power(long x, long y)
          {
              long res = 1;     // Initialize result
          
              while (y > 0)
              {
              
                  // If y is odd, multiply x with result
                  if ((y & 1) != 0)
                      res = res * x;
          
                  // y must be even now
                  y = y >> 1; // y = y/2
                  x = x * x;  // Change x to x^2
              }
              return res;
          }
  
          static class pair{
              long a;
              long b;
              pair(long c, long d){
                  a=c;
                  b=d;
              }
          }
          static class yoyo implements Comparator<pair>{
  
             
              public int compare(pair o1, pair o2) {
                  // TODO Auto-generated method stub
                   if(o1.a<o2.a){
                       return -1;
                   }
                   else{
                       return 1;
                   }
              }
              
          }
  
  
  
  
  
  }