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.OutputStream;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.PrintWriter;
  import java.io.OutputStream;
  import java.util.Arrays;
  import java.io.IOException;
  import java.util.InputMismatchException;
  import java.io.InputStreamReader;
  import java.io.Writer;
  import java.io.BufferedReader;
  import java.util.NoSuchElementException;
  import java.io.InputStream;
  
  /**
   * Built using CHelper plug-in
   * Actual solution is at the top
   *
   * @author Nipuna Samarasekara
   */
  public class Main {
      public static void main(String[] args) {
          InputStream inputStream = System.in;
          OutputStream outputStream = System.out;
          FastScanner in = new FastScanner(inputStream);
          FastPrinter out = new FastPrinter(outputStream);
          TaskC solver = new TaskC();
          solver.solve(1, in, out);
          out.close();
      }
  
      static class TaskC {
          public void solve(int testNumber, FastScanner in, FastPrinter out) {
              int t = in.nextInt();
              while (t-- > 0) {
                  int n = in.nextInt();
                  int[] a = in.readIntArray(n);
                  int[] b = in.readIntArray(n);
                  ArrayUtils.compress(a);
                  ArrayUtils.compress(b);
  
  
                  int amax = 0, mi = 0;
                  MinSegmentTree mstA = new MinSegmentTree(n + 10);
                  MinSegmentTree mstB = new MinSegmentTree(n + 10);
                  for (int i = 0; i < n; i++) {
                      if (a[i] > amax) {
                          amax = a[i];
                          mi = i;
                      }
                      mstA.set(a[i], b[i]);
                      mstB.set(b[i], a[i]);
                  }
  
                  int ab = 1;
                  int amin = amax;
                  int bmin = mstA.getMin(amin, n + 1);
                  boolean good = true;
                  while (good) {
                      good = false;
                      if (ab == 1) {
                          int na = mstB.getMin(bmin, n + 1);
                          if (na < amin) {
                              amin = na;
                              good = true;
                          }
                      } else {
                          int na = mstA.getMin(amin, n + 1);
                          if (na < bmin) {
                              bmin = na;
                              good = true;
                          }
  
                      }
                      ab = 1 - ab;
  
                  }
  
  
                  StringBuilder sb = new StringBuilder();
                  for (int i = 0; i < n; i++) {
                      if (a[i] >= amin || b[i] >= bmin) {
                          sb.append("1");
                      } else {
                          sb.append("0");
                      }
  
                  }
                  out.println(sb.toString());
              }
          }
  
      }
  
      static interface IntIterator {
          public int value() throws NoSuchElementException;
  
          public void advance() throws NoSuchElementException;
  
          public boolean isValid();
  
      }
  
      static class IntSortedArray extends IntSortedList {
          private final int[] array;
  
          public IntSortedArray(int[] array) {
              this(array, IntComparator.DEFAULT);
          }
  
          public IntSortedArray(IntCollection collection) {
              this(collection, IntComparator.DEFAULT);
          }
  
          public IntSortedArray(int[] array, IntComparator comparator) {
              super(comparator);
              this.array = array;
              ensureSorted();
          }
  
          public IntSortedArray(IntCollection collection, IntComparator comparator) {
              super(comparator);
              array = new int[collection.size()];
              int i = 0;
              for (IntIterator iterator = collection.iterator(); iterator.isValid();
                   iterator.advance())
                  array[i++] = iterator.value();
              ensureSorted();
          }
  
          public int get(int index) {
              return array[index];
          }
  
          public int size() {
              return array.length;
          }
  
      }
  
      static abstract class IntSortedList extends IntList {
          protected final IntComparator comparator;
  
          protected IntSortedList(IntComparator comparator) {
              this.comparator = comparator;
          }
  
          public void set(int index, int value) {
              throw new UnsupportedOperationException();
          }
  
          public IntSortedList inPlaceSort(IntComparator comparator) {
              if (comparator == this.comparator) {
                  return this;
              }
              throw new UnsupportedOperationException();
          }
  
          protected void ensureSorted() {
              int size = size();
              if (size == 0) {
                  return;
              }
              int last = get(0);
              for (int i = 1; i < size; i++) {
                  int current = get(i);
                  if (comparator.compare(last, current) > 0) {
                      throw new IllegalArgumentException();
                  }
                  last = current;
              }
          }
  
          public IntSortedList subList(final int from, final int to) {
              return new IntSortedList(comparator) {
                  private int size = to - from;
  
  
                  public int get(int index) {
                      if (index < 0 || index >= size) {
                          throw new IndexOutOfBoundsException();
                      }
                      return IntSortedList.this.get(index + from);
                  }
  
  
                  public int size() {
                      return size;
                  }
              };
          }
  
      }
  
      static class FastScanner extends BufferedReader {
          public FastScanner(InputStream is) {
              super(new InputStreamReader(is));
          }
  
          public int read() {
              try {
                  int ret = super.read();
                  //            if (isEOF && ret < 0) {
                  //                throw new InputMismatchException();
                  //            }
                  //            isEOF = ret == -1;
                  return ret;
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
          }
  
          static boolean isWhiteSpace(int c) {
              return c >= 0 && c <= 32;
          }
  
          public int nextInt() {
              int c = read();
              while (isWhiteSpace(c)) {
                  c = read();
              }
              int sgn = 1;
              if (c == '-') {
                  sgn = -1;
                  c = read();
              }
              int ret = 0;
              while (c >= 0 && !isWhiteSpace(c)) {
                  if (c < '0' || c > '9') {
                      throw new NumberFormatException("digit expected " + (char) c + " found");
                  }
                  ret = ret * 10 + c - '0';
                  c = read();
              }
              return ret * sgn;
          }
  
          public String readLine() {
              try {
                  return super.readLine();
              } catch (IOException e) {
                  return null;
              }
          }
  
          public int[] readIntArray(int n) {
              int[] ret = new int[n];
              for (int i = 0; i < n; i++) {
                  ret[i] = nextInt();
              }
              return ret;
          }
  
      }
  
      static class MinSegmentTree {
          int[] min;
          int[] minId;
          int n;
  
          public MinSegmentTree(int n) {
              this.n = Integer.highestOneBit(n) << 1;
              min = new int[this.n * 2];
              minId = new int[this.n * 2];
              for (int i = 0; i < n; i++) {
                  minId[i + n] = i;
              }
              for (int i = 0; i < n; i++) {
                  set(i, Integer.MAX_VALUE);
              }
          }
  
          public void set(int x, int y) {
              x += n;
              min[x] = y;
              while (x > 1) {
                  x >>= 1;
                  int left = min[x << 1];
                  int right = min[(x << 1) | 1];
                  if (left <= right) {
                      min[x] = left;
                      minId[x] = minId[x << 1];
                  } else {
                      min[x] = right;
                      minId[x] = minId[(x << 1) | 1];
                  }
              }
          }
  
          public int getMin(int left, int right) {
              --right;
              left += n;
              right += n;
              int ret = Integer.MAX_VALUE;
              while (left <= right) {
                  if ((left & 1) == 1) {
                      ret = Math.min(ret, min[left]);
                      left++;
                  }
                  if ((right & 1) == 0) {
                      ret = Math.min(ret, min[right]);
                      right--;
                  }
                  left >>= 1;
                  right >>= 1;
              }
              return ret;
          }
  
      }
  
      static interface IntComparator {
          public static final IntComparator DEFAULT = new IntComparator() {
              public int compare(int first, int second) {
                  if (first < second) {
                      return -1;
                  }
                  if (first > second) {
                      return 1;
                  }
                  return 0;
              }
          };
  
          public int compare(int first, int second);
  
      }
  
      static class ArrayUtils {
          public static int[] sort(int[] array, IntComparator comparator) {
              return sort(array, 0, array.length, comparator);
          }
  
          public static int[] sort(int[] array, int from, int to, IntComparator comparator) {
              if (from == 0 && to == array.length) {
                  new IntArray(array).inPlaceSort(comparator);
              } else {
                  new IntArray(array).subList(from, to).inPlaceSort(comparator);
              }
              return array;
          }
  
          public static int[] unique(int[] array) {
              return unique(array, 0, array.length);
          }
  
          public static int[] unique(int[] array, int from, int to) {
              if (from == to) {
                  return new int[0];
              }
              int count = 1;
              for (int i = from + 1; i < to; i++) {
                  if (array[i] != array[i - 1]) {
                      count++;
                  }
              }
              int[] result = new int[count];
              result[0] = array[from];
              int index = 1;
              for (int i = from + 1; i < to; i++) {
                  if (array[i] != array[i - 1]) {
                      result[index++] = array[i];
                  }
              }
              return result;
          }
  
          public static int[] compress(int[]... arrays) {
              int totalLength = 0;
              for (int[] array : arrays)
                  totalLength += array.length;
              int[] all = new int[totalLength];
              int delta = 0;
              for (int[] array : arrays) {
                  System.arraycopy(array, 0, all, delta, array.length);
                  delta += array.length;
              }
              sort(all, IntComparator.DEFAULT);
              all = unique(all);
              for (int[] array : arrays) {
                  for (int i = 0; i < array.length; i++)
                      array[i] = Arrays.binarySearch(all, array[i]);
              }
              return all;
          }
  
      }
  
      static class FastPrinter extends PrintWriter {
          public FastPrinter(OutputStream out) {
              super(out);
          }
  
          public FastPrinter(Writer out) {
              super(out);
          }
  
      }
  
      static abstract class IntList extends IntCollection implements Comparable<IntList> {
          private static final int INSERTION_THRESHOLD = 16;
  
          public abstract int get(int index);
  
          public abstract void set(int index, int value);
  
          public IntIterator iterator() {
              return new IntIterator() {
                  private int size = size();
                  private int index = 0;
  
                  public int value() throws NoSuchElementException {
                      if (!isValid()) {
                          throw new NoSuchElementException();
                      }
                      return get(index);
                  }
  
                  public void advance() throws NoSuchElementException {
                      if (!isValid()) {
                          throw new NoSuchElementException();
                      }
                      index++;
                  }
  
                  public boolean isValid() {
                      return index < size;
                  }
              };
          }
  
          public IntList subList(final int from, final int to) {
              return new SubList(from, to);
          }
  
          private void swap(int first, int second) {
              if (first == second) {
                  return;
              }
              int temp = get(first);
              set(first, get(second));
              set(second, temp);
          }
  
          public IntSortedList inPlaceSort(IntComparator comparator) {
              quickSort(0, size() - 1, (Integer.bitCount(Integer.highestOneBit(size()) - 1) * 5) >> 1,
                      comparator);
              return new IntSortedArray(this, comparator);
          }
  
          private void quickSort(int from, int to, int remaining, IntComparator comparator) {
              if (to - from < INSERTION_THRESHOLD) {
                  insertionSort(from, to, comparator);
                  return;
              }
              if (remaining == 0) {
                  heapSort(from, to, comparator);
                  return;
              }
              remaining--;
              int pivotIndex = (from + to) >> 1;
              int pivot = get(pivotIndex);
              swap(pivotIndex, to);
              int storeIndex = from;
              int equalIndex = to;
              for (int i = from; i < equalIndex; i++) {
                  int value = comparator.compare(get(i), pivot);
                  if (value < 0) {
                      swap(storeIndex++, i);
                  } else if (value == 0) {
                      swap(--equalIndex, i--);
                  }
              }
              quickSort(from, storeIndex - 1, remaining, comparator);
              for (int i = equalIndex; i <= to; i++)
                  swap(storeIndex++, i);
              quickSort(storeIndex, to, remaining, comparator);
          }
  
          private void heapSort(int from, int to, IntComparator comparator) {
              for (int i = (to + from - 1) >> 1; i >= from; i--)
                  siftDown(i, to, comparator, from);
              for (int i = to; i > from; i--) {
                  swap(from, i);
                  siftDown(from, i - 1, comparator, from);
              }
          }
  
          private void siftDown(int start, int end, IntComparator comparator, int delta) {
              int value = get(start);
              while (true) {
                  int child = ((start - delta) << 1) + 1 + delta;
                  if (child > end) {
                      return;
                  }
                  int childValue = get(child);
                  if (child + 1 <= end) {
                      int otherValue = get(child + 1);
                      if (comparator.compare(otherValue, childValue) > 0) {
                          child++;
                          childValue = otherValue;
                      }
                  }
                  if (comparator.compare(value, childValue) >= 0) {
                      return;
                  }
                  swap(start, child);
                  start = child;
              }
          }
  
          private void insertionSort(int from, int to, IntComparator comparator) {
              for (int i = from + 1; i <= to; i++) {
                  int value = get(i);
                  for (int j = i - 1; j >= from; j--) {
                      if (comparator.compare(get(j), value) <= 0) {
                          break;
                      }
                      swap(j, j + 1);
                  }
              }
          }
  
          public int hashCode() {
              int hashCode = 1;
              for (IntIterator i = iterator(); i.isValid(); i.advance())
                  hashCode = 31 * hashCode + i.value();
              return hashCode;
          }
  
          public boolean equals(Object obj) {
              if (!(obj instanceof IntList)) {
                  return false;
              }
              IntList list = (IntList) obj;
              if (list.size() != size()) {
                  return false;
              }
              IntIterator i = iterator();
              IntIterator j = list.iterator();
              while (i.isValid()) {
                  if (i.value() != j.value()) {
                      return false;
                  }
                  i.advance();
                  j.advance();
              }
              return true;
          }
  
          public int compareTo(IntList o) {
              IntIterator i = iterator();
              IntIterator j = o.iterator();
              while (true) {
                  if (i.isValid()) {
                      if (j.isValid()) {
                          if (i.value() != j.value()) {
                              if (i.value() < j.value()) {
                                  return -1;
                              } else {
                                  return 1;
                              }
                          }
                      } else {
                          return 1;
                      }
                  } else {
                      if (j.isValid()) {
                          return -1;
                      } else {
                          return 0;
                      }
                  }
                  i.advance();
                  j.advance();
              }
          }
  
          private class SubList extends IntList {
              private final int to;
              private final int from;
              private int size;
  
              public SubList(int from, int to) {
                  this.to = to;
                  this.from = from;
                  size = to - from;
              }
  
              public int get(int index) {
                  if (index < 0 || index >= size) {
                      throw new IndexOutOfBoundsException();
                  }
                  return IntList.this.get(index + from);
              }
  
              public void set(int index, int value) {
                  if (index < 0 || index >= size) {
                      throw new IndexOutOfBoundsException();
                  }
                  IntList.this.set(index + from, value);
              }
  
              public int size() {
                  return size;
              }
  
          }
  
      }
  
      static abstract class IntCollection {
          public abstract IntIterator iterator();
  
          public abstract int size();
  
      }
  
      static class IntArray extends IntList {
          private final int[] array;
  
          public IntArray(int[] array) {
              this.array = array;
          }
  
          public IntArray(IntCollection collection) {
              array = new int[collection.size()];
              int i = 0;
              for (IntIterator iterator = collection.iterator(); iterator.isValid();
                   iterator.advance())
                  array[i++] = iterator.value();
          }
  
          public int get(int index) {
              return array[index];
          }
  
          public void set(int index, int value) {
              array[index] = value;
          }
  
          public int size() {
              return array.length;
          }
  
      }
  }
  
  