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.io.*;
  import java.util.*;
  
  public class CodeForces{
      /*-------------------------------------------EDITING CODE STARTS HERE-------------------------------------------*/
  
      public static void main(String[] args) throws IOException{
          openIO();
          int testCase = 1;
          testCase = sc.nextInt();
          for (int i = 1; i <= testCase; i++) solve(i);
          closeIO();
      }
      public static void solve(int tCase)throws IOException {
          int n= sc.nextInt();
          int[][] arr = new int[n][3];
          adj = new ArrayList[n];
          for(int i=0;i<n;i++){
              arr[i][0] = sc.nextInt();
              arr[i][2] = i;
              adj[i] = new ArrayList<>();
          }
          for(int i = 0 ;i<n;i++){
              arr[i][1] = sc.nextInt();
          }
          win = new boolean[n];
          Arrays.sort(arr,(a,b)->(a[0]-b[0]));
          for(int i=1;i<n;i++)adj[arr[i-1][2]].add(arr[i][2]);
          int s1 = arr[n-1][2];
          Arrays.sort(arr,(a,b)->(a[1] - b[1]));
          for(int i=1;i<n;i++)adj[arr[i-1][2]].add(arr[i][2]);
          int s2 = arr[n-1][2];
          dfs(s1);
          dfs(s2);
          for(int i=0;i<n;i++)out.print(win[i]?'1':'0');
          out.println();
  
      }
      static ArrayList<Integer>[] adj;
      static boolean[] win;
      private static void dfs(int curr){
          win[curr] = true;
          for(int neig : adj[curr]){
              if(!win[neig])dfs(neig);
          }
      }
  
      /*-------------------------------------------EDITING CODE ENDS HERE-------------------------------------------*/
      static FastestReader sc;
      static PrintWriter out;
      private static void openIO() throws IOException{
          sc = new FastestReader();
          out = new PrintWriter(System.out);
      }
  
      /*------------------------------------------HELPER FUNCTION STARTS HERE------------------------------------------*/
  
      public static int mod = (int) 1e9 + 7;
      private static int mod2 =  998244353;
      public static int inf_int = (int) 2e9 + 10;
      public static  long inf_long = (long) 2e15;
  
  
      public static int _digitCount(long num,int base){
          return (int)(1 + Math.log(num)/Math.log(base));
      }
      public static long _fact(int n){
          long ans = 1;
          for(int i=2;i<=n;i++)
              ans = ans * i % mod;
          return ans;
      }
      // time : O(r)
      public static int _ncr(int n,int r){
          if (r > n) return 0;
          long[]  inv = new long[r + 1];
          inv[0] = 1;
          if(r+1>=2)
              inv[1] = 1;
  
          // Getting the modular inversion
          // for all the numbers
          // from 2 to r with respect to mod
          for (int i = 2; i <= r; i++)
              inv[i] = mod - (mod / i) * inv[(mod % i)] % mod;
  
          int ans = 1;
  
          // for 1/(r!) part
          for (int i = 2; i <= r; i++)
              ans = (int) (((ans % mod) * (inv[i] % mod)) % mod);
  
          // for (n)*(n-1)*(n-2)*...*(n-r+1) part
          for (int i = n; i >= (n - r + 1); i--)
              ans =  (((ans % mod) * (i % mod)) % mod);
          return ans;
      }
  
      // euclidean algorithm time O(max (loga ,logb))
      public static long _gcd(long a, long b) {
          if (a == 0)
              return b;
          return _gcd(b % a, a);
      }
  
      public static long _lcm(long a, long b) {
          // lcm(a,b) * gcd(a,b) = a * b
          return (a / _gcd(a, b)) * b;
      }
  
  
      // binary exponentiation time O(logn)
      public static long _power(long x, long n) {
          long ans = 1;
          while (n > 0) {
              if ((n & 1) == 1) {
                  ans *= x;
                  ans %= mod;
                  n--;
              } else {
                  x *= x;
                  x %= mod;
                  n >>= 1;
              }
          }
          return ans;
      }
      //sieve/first divisor time : O(mx * log ( log (mx) ) )
      public static int[]  _seive(int mx){
          int[] firstDivisor = new int[mx+1];
          for(int i=0;i<=mx;i++)firstDivisor[i] = i;
          for(int i=2;i*i<=mx;i++)
              if(firstDivisor[i] == i)
                  for(int j = i*i;j<=mx;j+=i)
                      firstDivisor[j] = i;
          return firstDivisor;
      }
  
      private static boolean _isPrime(long x){
          for(long i=2;i*i<=x;i++)
              if(x%i==0)return false;
          return true;
      }
  
      public static void _sort(int[] arr,boolean isAscending){
          int n = arr.length;
          List<Integer> list = new ArrayList<>();
          for(int ele : arr)list.add(ele);
          Collections.sort(list);
          if(!isAscending)Collections.reverse(list);
          for(int i=0;i<n;i++)arr[i] = list.get(i);
      }
  
      public static void _sort(long[] arr,boolean isAscending){
          int n = arr.length;
          List<Long> list = new ArrayList<>();
          for(long ele : arr)list.add(ele);
          Collections.sort(list);
          if(!isAscending)Collections.reverse(list);
          for(int i=0;i<n;i++)arr[i] = list.get(i);
      }
      /*------------------------------------------HELPER FUNCTION ENDS HERE-------------------------------------------*/
  
      /*-------------------------------------------FAST INPUT STARTS HERE---------------------------------------------*/
  
      public static void closeIO() throws IOException{
          out.flush();
          out.close();
          sc.close();
      }
      private static final class FastestReader {
          private static final int BUFFER_SIZE = 1 << 16;
          private final DataInputStream din;
          private final byte[] buffer;
          private int bufferPointer, bytesRead;
  
          public FastestReader() {
              din = new DataInputStream(System.in);
              buffer = new byte[BUFFER_SIZE];
              bufferPointer = bytesRead = 0;
          }
  
          public FastestReader(String file_name) throws IOException {
              din = new DataInputStream(new FileInputStream(file_name));
              buffer = new byte[BUFFER_SIZE];
              bufferPointer = bytesRead = 0;
          }
  
          private static boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
  
          private int skip() throws IOException {
              int b;
              //noinspection StatementWithEmptyBody
              while ((b = read()) != -1 && isSpaceChar(b)) {}
              return b;
          }
  
          public String next() throws IOException {
              int b = skip();
              final StringBuilder sb = new StringBuilder();
              while (!isSpaceChar(b)) { // when nextLine, (isSpaceChar(b) && b != ' ')
                  sb.appendCodePoint(b);
                  b = read();
              }
              return sb.toString();
          }
  
          public int nextInt() throws IOException {
              int ret = 0;
              byte c = read();
              while (c <= ' ') {
                  c = read();
              }
              final boolean neg = c == '-';
              if (neg) { c = read(); }
              do {
                  ret = ret * 10 + c - '0';
              } while ((c = read()) >= '0' && c <= '9');
  
              if (neg) { return -ret; }
              return ret;
          }
  
          public long nextLong() throws IOException {
              long ret = 0;
              byte c = read();
              while (c <= ' ') { c = read(); }
              final boolean neg = c == '-';
              if (neg) { c = read(); }
              do {
                  ret = ret * 10 + c - '0';
              } while ((c = read()) >= '0' && c <= '9');
              if (neg) { return -ret; }
              return ret;
          }
  
          public double nextDouble() throws IOException {
              double ret = 0, div = 1;
              byte c = read();
              while (c <= ' ') { c = read(); }
              final boolean neg = c == '-';
              if (neg) { c = read(); }
  
              do {
                  ret = ret * 10 + c - '0';
              } while ((c = read()) >= '0' && c <= '9');
  
              if (c == '.') {
                  while ((c = read()) >= '0' && c <= '9') {
                      ret += (c - '0') / (div *= 10);
                  }
              }
  
              if (neg) { return -ret; }
              return ret;
          }
  
          private void fillBuffer() throws IOException {
              bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
              if (bytesRead == -1) { buffer[0] = -1; }
          }
  
          private byte read() throws IOException {
              if (bufferPointer == bytesRead) { fillBuffer(); }
              return buffer[bufferPointer++];
          }
  
          public void close() throws IOException {
              din.close();
          }
      }
      /*---------------------------------------------FAST INPUT ENDS HERE ---------------------------------------------*/
  }