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 Solution {
  
  	static Scanner sc = new Scanner(System.in);
  	// static Reader sc = new Reader();
  	static StringBuilder out = new StringBuilder();
  
  	static String testCase = "Case #";
  	static long mod = 998244353;
  
  	public static void main(String[] args) throws IOException {
  		// TODO Auto-generated method stub
  
  		int t = sc.nextInt();
  
  		int tc = 0;
  
  		while (tc++ < t) {
  			
  			Solution run = new Solution();
  			
  			run.run();
  		}
  
  		System.out.println(out);
  
  	}
  
  	static ArrayList<Integer> gr[];
  	public void run() throws IOException {
  
  		
  		int n=sc.nextInt();
  		int a[][]=new int [n][2];
  		int b[][]=new int [n][2];
  		
  		gr=new ArrayList[n];
  		for(int i=0;i<n;i++) {
  			
  			a[i][0]=sc.nextInt();
  			a[i][1]=i;
  			gr[i]=new ArrayList<Integer>();
  			
  		}
  		
  		for(int i=0;i<n;i++) {
  			b[i][0]=sc.nextInt();
  			b[i][1]=i;
  			
  		}
  		
  		Arrays.sort(a,(c,d)-> (d[0]-c[0]));
  		Arrays.sort(b,(c,d)-> (d[0]-c[0]));
  		
  		for(int i=1;i<n;i++) {
  			
  			gr[a[i][1]].add(a[i-1][1]);
  			gr[b[i][1]].add(b[i-1][1]);
  		}
  		
  		int root=0;
  		
  		if(a[0][0]>=b[0][0]) {
  			
  			root=a[0][1];
  		}
  		else root= b[0][1];
  		
  		visit =new boolean [n];
  		
  		dfs(root);
  		
  		for(int i=0;i<n;i++) {
  			if(visit[i])out.append(1);
  			else out.append(0);
  		}
  		
  		out.append("\n");
  		
  		
  		
  	}
  	
  	static boolean visit[];
  	static void dfs(int u) {
  		
  		visit[u]=true;
  		
  		
  		for(int ch : gr[u]) {
  			
  			if(!visit[ch]) {
  				
  				dfs(ch);
  				
  			}
  		}
  		
  		
  	}
  	
  	
  	
  	static int bit[];
  
  	static void modify(int x, int val) {
  
  		for (; x < bit.length; x += (x & -x))
  			bit[x] += val;
  
  	}
  
  	static int get(int x) {
  
  		int sum = 0;
  
  		for (; x > 0; x -= (x & -x))
  			sum += bit[x];
  
  		return sum;
  	}
  
  
  	static long modInverse(long a, long m) {
  		long m0 = m;
  		long y = 0, x = 1;
  
  		if (m == 1)
  			return 0;
  
  		while (a > 1) {
  			// q is quotient
  			long q = a / m;
  
  			long t = m;
  
  			m = a % m;
  			a = t;
  			t = y;
  
  			// Update x and y
  			y = x - q * y;
  			x = t;
  		}
  
  		// Make x positive
  		if (x < 0)
  			x += m0;
  
  		return x;
  	}
  
  	static class Reader {
  		final private int BUFFER_SIZE = 1 << 16;
  		private DataInputStream din;
  		private byte[] buffer;
  		private int bufferPointer, bytesRead;
  
  		public Reader() {
  			din = new DataInputStream(System.in);
  			buffer = new byte[BUFFER_SIZE];
  			bufferPointer = bytesRead = 0;
  		}
  
  		public Reader(String file_name) throws IOException {
  			din = new DataInputStream(new FileInputStream(file_name));
  			buffer = new byte[BUFFER_SIZE];
  			bufferPointer = bytesRead = 0;
  		}
  
  		public String readLine() throws IOException {
  			byte[] buf = new byte[64]; // line length
  			int cnt = 0, c;
  			while ((c = read()) != -1) {
  				if (c == '\n') {
  					if (cnt != 0) {
  						break;
  					} else {
  						continue;
  					}
  				}
  				buf[cnt++] = (byte) c;
  			}
  			return new String(buf, 0, cnt);
  		}
  
  		public int nextInt() throws IOException {
  			int ret = 0;
  			byte c = read();
  			while (c <= ' ') {
  				c = read();
  			}
  			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();
  			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();
  			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 {
  			if (din == null)
  				return;
  			din.close();
  		}
  	}
  
  }
  