On the competitive programming platform CodeCook, every person has a rating graph described by an array of integers $a$ of length $n$. You are now updating the infrastructure, so you've created a program to compress these graphs.

The program works as follows. Given an integer parameter $k$, the program takes the minimum of each contiguous subarray of length $k$ in $a$.

More formally, for an array $a$ of length $n$ and an integer $k$, define the $k$-compression array of $a$ as an array $b$ of length $n-k+1$, such that $$b_j =\min_{j\le i\le j+k-1}a_i$$

For example, the $3$-compression array of $[1, 3, 4, 5, 2]$ is $[\min\{1, 3, 4\}, \min\{3, 4, 5\}, \min\{4, 5, 2\}]=[1, 3, 2].$

A permutation of length $m$ is an array consisting of $m$ distinct integers from $1$ to $m$ in arbitrary order. For example, $[2,3,1,5,4]$ is a permutation, but $[1,2,2]$ is not a permutation ($2$ appears twice in the array) and $[1,3,4]$ is also not a permutation ($m=3$ but there is $4$ in the array).

A $k$-compression array will make CodeCook users happy if it will be a permutation. Given an array $a$, determine for all $1\leq k\leq n$ if CodeCook users will be happy after a $k$-compression of this array or not.


-----Input-----

The first line contains a single integer $t$ ($1\leq t\leq 10^4$) — the number of test cases.

The first line of the description of each test case contains a single integer $n$ ($1\leq n\leq 3\cdot 10^5$) — the length of the array.

The second line of the description of each test case contains $n$ integers $a_1,\ldots,a_n$ ($1\leq a_i\leq n$) — the elements of the array.

It is guaranteed, that the sum of $n$ for all test cases does not exceed $3\cdot 10^5$.


-----Output-----

For each test case, print a binary string of length $n$.

The $k$-th character of the string should be $1$ if CodeCook users will be happy after a $k$-compression of the array $a$, and $0$ otherwise.


-----Examples-----

Input
5
5
1 5 3 4 2
4
1 3 2 1
5
1 3 3 3 2
10
1 2 3 4 5 6 7 8 9 10
3
3 3 2
Output
10111
0001
00111
1111111111
000


-----Note-----

In the first test case, $a=[1, 5, 3, 4, 2]$.

The $1$-compression of $a$ is $[1, 5, 3, 4, 2]$ and it is a permutation.

The $2$-compression of $a$ is $[1, 3, 3, 2]$ and it is not a permutation, since $3$ appears twice.

The $3$-compression of $a$ is $[1, 3, 2]$ and it is a permutation.

The $4$-compression of $a$ is $[1, 2]$ and it is a permutation.

The $5$-compression of $a$ is $[1]$ and it is a permutation.

Difficulty: MEDIUM_HARD
Tags: Sorting

Amortized analysis

Implementation

Greedy algorithms

Data structures
Skill types: Data structures

Sorting

Amortized analysis

Greedy algorithms

Starter code:

Solutions:
from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from functools import cmp_to_key
from heapq import *
from math import gcd, factorial, floor, ceil, sqrt
from copy import deepcopy
from collections import deque
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def testcase(t):
	for pp in range(t):
		solve(pp)

def google(p):
	print('Case #' + str(p) + ': ', end='')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(x, y, p):
	y %= p - 1
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
inf = pow(10, 20)
mod = 10 ** 9 + 7

class RangeQuery:

	def __init__(self, data, func=min):
		self.func = func
		self._data = _data = [list(data)]
		(i, n) = (1, len(_data[0]))
		while 2 * i <= n:
			prev = _data[-1]
			_data.append([func(prev[j], prev[j + i]) for j in range(n - 2 * i + 1)])
			i <<= 1

	def query(self, start, stop):
		depth = (stop - start).bit_length() - 1
		return self.func(self._data[depth][start], self._data[depth][stop - (1 << depth)])

def solve(case):
	n = int(inp())
	a = lis()
	rmq = RangeQuery(a)
	ans = [0] * n
	l = 0
	r = n - 1
	for i in range(1, n):
		f = False
		if a[l] == i:
			if rmq.query(l + 1, r + 1) == i + 1:
				l += 1
				f = True
				ans[n - i] = 1
		if not f and a[r] == i:
			if rmq.query(l, r) == i + 1:
				r -= 1
				f = True
				ans[n - i] = 1
		if not f and (a[l] == i or a[r] == i or rmq.query(l, r + 1) == i):
			ans[n - i] = 1
		if not f:
			break
	if len(set(a)) == n and min(a) == 1 and (max(a) == n):
		ans[0] = 1
	print(''.join((str(ans[i]) for i in range(n))))
testcase(int(inp()))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for j in range(int(input())):
	n = int(input())
	vals = list(map(int, input().split()))
	ans = ['0' for s in range(n)]
	sorts = [(vals[s], s) for s in range(n)]
	sorts.sort(key=lambda x: x[0])
	if sorts[0][0] == 1:
		ans[n - 1] = '1'
	l = 0
	r = n - 1
	for s in range(n - 1):
		if sorts[s][0] == s + 1:
			pos = sorts[s][1]
			if pos == l:
				if sorts[s + 1][0] == s + 2:
					ans[n - 2 - s] = '1'
					l += 1
				else:
					break
			elif pos == r:
				if sorts[s + 1][0] == s + 2:
					ans[n - 2 - s] = '1'
					r -= 1
				else:
					break
			else:
				break
		else:
			break
	if set(vals) == set([s for s in range(1, n + 1)]):
		ans[0] = '1'
	print(''.join(ans))


import sys
t = int(input())
for test in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	s = [[] for i in range(n + 1)]
	res = ['1' for i in range(n)]
	for i in range(n):
		if s[a[i]] != []:
			res[0] = '0'
		s[a[i]].append(i)
	k = 0
	for i in range(1, n + 1):
		if len(s[i]) == 0:
			for j in range(0, n - i + 1):
				res[j] = '0'
			break
		elif len(s[i]) > 1:
			for j in range(0, n - i):
				res[j] = '0'
			break
		elif s[i][0] == k:
			k += 1
		elif s[i][0] != n - i + k:
			for j in range(1, n - i):
				res[j] = '0'
			break
	print(''.join(res))


t = int(input())
for tt in range(t):
	n = int(input())
	array = [int(x) for x in input().split()]
	cnt = [0] * (n + 1)
	ans = []
	for e in array:
		cnt[e] += 1
	flag = True
	l = 0
	r = n - 1
	for i in range(1, n):
		if flag and cnt[i]:
			ans.append(1)
		else:
			ans.append(0)
		if cnt[i] != 1:
			flag = False
		elif array[l] == i:
			l += 1
		elif array[r] == i:
			r -= 1
		else:
			flag = False
	aux = set(array)
	if len(aux) == n:
		ans.append(1)
	else:
		ans.append(0)
	ans.reverse()
	for e in ans:
		print(e, end='')
	print()


import sys
input = sys.stdin.buffer.readline

def prog():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		mn = min(a)
		counts = [0] * (n + 1)
		for i in a:
			counts[i] += 1
		output = ['0' for i in range(n)]
		if sorted(a) == [i for i in range(1, n + 1)]:
			output[0] = '1'
		l = 0
		r = n - 1
		for i in range(1, n):
			if mn != i:
				break
			if a[l] == i:
				counts[a[l]] -= 1
				l += 1
				output[n - i] = '1'
				while counts[mn] == 0:
					mn += 1
			elif a[r] == i:
				counts[a[r]] -= 1
				r -= 1
				output[n - i] = '1'
				while counts[mn] == 0:
					mn += 1
			else:
				output[n - i] = '1'
				break
		print(''.join(output))
prog()


def read_ints():
	return map(int, input().split())
(t_n,) = read_ints()
for i_t in range(t_n):
	(n,) = read_ints()
	a_seq = tuple(read_ints())
	result = [None] * n
	result[0] = sorted(a_seq) == list(range(1, n + 1))
	a_need = 1
	(i, j) = (0, n - 1)
	has_analogue = False
	while i <= j and (a_seq[i] == a_need or a_seq[j] == a_need):
		if a_seq[i] == a_need and a_seq[j] == a_need and (i != j):
			i += 1
			a_need += 1
			has_analogue = True
			break
		else:
			if a_seq[i] == a_need:
				i += 1
			else:
				j -= 1
			a_need += 1
	wrong_segment_length = j - i + 1
	if not has_analogue:
		min_k = wrong_segment_length
		wrong_segment_min = min(a_seq[i:j + 1], default=n + 1)
	else:
		min_k = wrong_segment_length + 1
		wrong_segment_min = min(a_seq[i:j + 1])
	if wrong_segment_min == a_need:
		min_k = max(min_k, wrong_segment_length)
	elif wrong_segment_min > a_need:
		min_k = max(min_k, wrong_segment_length + 1)
	else:
		while wrong_segment_min != a_need:
			a_need -= 1
			wrong_segment_length += 1
		min_k = max(min_k, wrong_segment_length)
	for k in range(min_k, n + 1):
		result[k - 1] = True
	print(''.join(['1' if result[i] else '0' for i in range(n)]))


from collections import defaultdict, deque
import sys
import bisect
input = sys.stdin.readline
t = int(input())
for ii in range(t):
	n = int(input())
	l = [int(i) for i in input().split() if i != '\n']
	ind = defaultdict(list)
	ind_arr = [0] * (n + 1)
	stack = []
	for i in range(len(l)):
		if l[i] >= 0:
			ind_arr[l[i]] = i
			while len(stack) > 0 and stack[-1] > l[i]:
				temp = stack.pop()
				if i != ind[temp][-1][-1]:
					ind[temp][-1].append(i)
			if len(stack) == 0:
				ind[l[i]].append([0])
			elif stack[-1] != l[i]:
				ind[l[i]].append([ind_arr[stack[-1]] + 1])
			stack.append(l[i])
	count = []
	for i in range(1, n + 1):
		if i in ind:
			(maxa, length) = (0, 0)
			for j in ind[i]:
				if len(j) == 1:
					length = n - j[0]
				else:
					length = j[1] - j[0]
				maxa = max(maxa, length)
			count.append(maxa)
		else:
			count.append(0)
	suff = [count[0]]
	ans = [0] * n
	for i in range(1, n):
		suff.append(min(suff[-1], count[i]))
	for i in range(n - 1, -1, -1):
		req = n - i
		if suff[i] == req:
			ans[req - 1] = 1
	ans = ''.join(map(str, ans))
	print(ans)


import sys
for _ in range(int(sys.stdin.readline())):
	n = int(sys.stdin.readline())
	a = list(map(int, sys.stdin.readline().strip().split(' ')))
	i = 0
	j = n - 1
	onec = 0
	oc = 0
	iso = 'ö'
	d = 0
	for k in range(1, n):
		if a[i] < k or a[j] < k:
			d = k - 1
			break
		elif a[i] == k:
			onec += 1
			i += 1
		elif a[j] == k:
			onec += 1
			j -= 1
		else:
			d = k
			break
	if i < j + 1:
		m = min(a[i:j + 1])
		if m <= d:
			onec = m * 1
	oc = n - 1 - onec
	r = []
	for i in range(1, n + 1):
		r.append(0)
	for i in a:
		if r[i - 1] == 0:
			r[i - 1] += 1
		else:
			iso = '0'
			break
	else:
		iso = '1'
	sys.stdout.write(iso + '0' * oc + '1' * onec + '\n')


from collections import *
from heapq import *
from itertools import *
from functools import *
from random import *
import sys
INF = float('Inf')

def genTokens(lines):
	for line in lines:
		for token in line.split():
			yield token

def nextFn(fn):
	return lambda it: fn(it.__next__())
nint = nextFn(int)

def genCases():
	it = genTokens(sys.stdin)
	T = nint(it)
	for _ in range(T):
		N = nint(it)
		As = [nint(it) for _ in range(N)]
		yield (N, As)

def main():
	for case in genCases():
		solve(case)

def solve(case):
	(N, As) = case
	index = dict()
	for (i, a) in enumerate(As):
		if a not in index:
			index[a] = []
		index[a].append(i)
	mark = 0
	(lo, hi) = (0, N - 1)
	for num in range(1, N):
		if num not in index:
			break
		mark = num
		if len(index[num]) > 1:
			break
		if index[num][0] != lo and index[num][0] != hi:
			break
		if index[num][0] == lo:
			lo += 1
		else:
			hi -= 1
	sAs = set(As)
	if all((i in sAs for i in range(1, N + 1))):
		first = '1'
	else:
		first = '0'
	ones = mark * ['1']
	zeros = (N - 1 - mark) * ['0']
	print(''.join([first] + zeros + ones))
main()


import os
import sys
from io import BytesIO, IOBase
import threading
from bisect import bisect_right
from math import gcd, log
from collections import Counter
from pprint import pprint
from itertools import permutations

def main():
	n = int(input())
	arr = list(map(int, input().split()))
	c = Counter(arr)
	t = set(arr)
	s = set()
	ans = [0] * (n + 1)
	l = 0
	r = n - 1
	bol = True
	for i in range(1, n + 1):
		if i in t and len(s) == 0 and bol:
			ans[i] = 1
		if c[i] > 1:
			bol = False
		s.add(i)
		if l <= r and arr[l] == i:
			s.remove(arr[l])
			l += 1
		while r >= l and arr[r] == i and (arr[r] in s):
			s.remove(arr[r])
			r -= 1
	if len(t) == n:
		ans[-1] = 1
	print(''.join([str(i) for i in ans[n:0:-1]]))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	main()


from collections import deque
for iii in range(int(input())):
	d = deque()
	f = 1
	n = int(input())
	m = {i + 1: 0 for i in range(n)}
	s = map(int, input().split())
	for i in s:
		m[i] += 1
		if m[i] != 1:
			f = 0
		d.append(i)
	res = [0 for i in range(n)]
	if f:
		res[0] = 1
	if m[1]:
		res[-1] = 1
	for i in range(n, 2, -1):
		a = d.pop()
		b = d.popleft() if len(d) else -2
		if a == n - i + 1 and m[n - i + 2] and (m[n - i + 1] == 1):
			d.appendleft(b)
			res[i - 2] += 1
		elif b == n - i + 1 and m[n - i + 2] and (m[n - i + 1] == 1):
			d.append(a)
			res[i - 2] += 1
		else:
			break
	print(*res, sep='')


import sys
import math
from collections import defaultdict, Counter
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	d = defaultdict(list)
	s1 = set()
	for j in range(n):
		d[a[j]].append(j)
		s1.add(a[j])
	s = ['0'] * n
	l = 0
	r = n - 1
	for j in range(n - 1):
		l1 = len(d[j + 1])
		if l1 == 0:
			break
		elif l1 >= 2:
			s[n - j - 1] = '1'
			break
		elif d[j + 1][0] == l:
			l += 1
			s[n - j - 1] = '1'
		elif d[j + 1][0] == r:
			r -= 1
			s[n - j - 1] = '1'
		else:
			s[n - j - 1] = '1'
			break
	if len(s1) == n:
		s[0] = '1'
	print(''.join(s))


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
import threading
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class SegmentTree:

	def __init__(self, data, default=10 ** 10, func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)
MOD = 10 ** 9 + 7

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	(l, r) = (0, n - 1)
	s = SegmentTree(a)
	res = [0] * n
	if len(set(a)) == n:
		res[0] = 1
	if 1 in a:
		res[-1] = 1
	end = n
	for i in range(1, n + 1):
		if a[l] == i:
			l += 1
		elif a[r] == i:
			r -= 1
		else:
			end = i
			break
		if s.query(l, r) != i + 1:
			end = i
			break
	for i in range(n - end, n - 1):
		res[i] = 1
	print(*res, sep='')


import os, sys
from io import BytesIO, IOBase

def main():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		arr = [0] * n
		for i in a:
			arr[i - 1] += 1
		if arr[0]:
			ls = [1]
		else:
			for i in range(n):
				print(0, end='')
			print()
			continue
		(x, y) = (0, n - 1)
		for i in range(1, n):
			if a[x] == i and arr[i - 1] == 1 and arr[i]:
				x += 1
				ls.append(1)
			elif a[y] == i and arr[i - 1] == 1 and arr[i]:
				y -= 1
				ls.append(1)
			else:
				ls.append(0)
				while len(ls) != n:
					ls.append(0)
				break
		if arr == [1] * n:
			ls[-1] = 1
		for i in range(n - 1, -1, -1):
			print(ls[i], end='')
		print()
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = a[:]
	b.sort(reverse=1)
	l = 0
	r = n - 1
	ans = [0] * n
	for i in range(1, n + 1):
		if b[-1] == i:
			ans[n - i] = 1
			if a[l] == i:
				l += 1
				b.pop()
			elif a[r] == i:
				r -= 1
				b.pop()
		else:
			break
	if len(a) == len(set(a)):
		ans[0] = 1
	for i in ans:
		print(i, end='')
	print()


import sys, math
input = sys.stdin.readline
tree = [0]

def rin():
	return int(sys.stdin.readline().strip())

def build(arr):
	for i in range(n):
		tree[n + i] = arr[i]
	for i in range(n - 1, 0, -1):
		tree[i] = min(tree[i << 1], tree[i << 1 | 1])

def query(l, r):
	res = 1000000
	l += n
	r += n
	while l < r:
		if l & 1:
			res = min(res, tree[l])
			l += 1
		if r & 1:
			r -= 1
			res = min(res, tree[r])
		l >>= 1
		r >>= 1
	return res

def solution(A):
	return min(A) == 1 and max(A) == len(A) == len(set(A))
t = rin()
for _ in range(t):
	n = rin()
	arr = [int(i) for i in input().strip().split()]
	tree = [0] * (math.ceil(math.log2(n)) * n)
	tree.append(0)
	tree.append(0)
	build(arr)
	ans = []
	l = 0
	r = n - 1
	for i in range(1, n):
		t_min = query(l, r + 1)
		if t_min != i:
			for i in range(i, n):
				ans.append('0')
			break
		if arr[l] == i:
			l += 1
			ans.append('1')
		elif arr[r] == i:
			r -= 1
			ans.append('1')
		else:
			ans.append('1')
			for i in range(i + 1, n):
				ans.append('0')
			break
	if solution(arr):
		ans.append('1')
	else:
		ans.append('0')
	ans.reverse()
	print(''.join(ans))


from collections import deque

def cal(nums, k):
	q = deque()
	ans = []
	for (i, n) in enumerate(nums):
		while q and q[-1] > n:
			q.pop()
		q.append(n)
		if i >= k - 1:
			ans.append(q[0])
			if q[0] == nums[i - k + 1]:
				q.popleft()
	return ans
for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	start = 1 if len(set(A)) == n else 0
	if n == 1:
		ans = [1 if A[0] == 1 else 0]
		print(ans[0], end='')
	elif min(A) != 1:
		ans = [0] * n
		for a in ans:
			print(a, end='')
	else:
		(left, right) = (2, n)
		while left < right:
			mid = left + (right - left) // 2
			cur = cal(A, mid)
			if sorted(cur) == list(range(1, n - mid + 2)):
				right = mid
			else:
				left = mid + 1
		ans = [start] + [0] * (left - 2) + [1] * (n - left + 1)
		for a in ans:
			print(a, end='')
	print('')


import heapq
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	q = []
	for (i, x) in enumerate(a):
		heapq.heappush(q, (x, i))
	result = [0] * (n + 1)
	if 1 in a:
		result[n] = 1
		L = 0
		R = n - 1
		(x, i) = heapq.heappop(q)
		for k in range(n - 1, 1, -1):
			(nx, ni) = heapq.heappop(q)
			if nx == x + 1:
				if i == L:
					L += 1
					result[k] = 1
					(x, i) = (nx, ni)
				elif i == R:
					R -= 1
					result[k] = 1
					(x, i) = (nx, ni)
				else:
					break
			else:
				break
	if max(a) == n and len(set(a)) == n:
		result[1] = 1
	print(''.join(map(str, result[1:])))


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	right = [i + 1 for i in range(n)]
	left = [i - 1 for i in range(n)]
	idx = [[] for i in range(n)]
	for i in range(n):
		idx[a[i] - 1].append(i)
	t = []
	for i in range(n - 1, -1, -1):
		t += idx[i]
	idx = t
	memo = [0 for i in range(n)]
	for i in idx:
		(L, R) = (left[i] + 1, right[i] - 1)
		memo[a[i] - 1] = max(memo[a[i] - 1], R - L + 1)
		if left[i] == -1:
			if right[i] != n:
				left[right[i]] = -1
		elif right[i] != n:
			(right[left[i]], left[right[i]]) = (right[i], left[i])
		else:
			right[left[i]] = n
	Mini = [memo[i] for i in range(n)]
	for i in range(1, n):
		Mini[i] = min(Mini[i - 1], Mini[i])
	ans = []
	for i in range(n - 1, -1, -1):
		if Mini[i] >= n - i:
			ans.append('1')
		else:
			ans.append('0')
	print(''.join(ans))


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def gift():
	for _ in range(t):
		n = int(input())
		A = [int(a) - 1 for a in input().split()]
		C = [0] * n
		for a in A:
			C[a] += 1
		(l, r) = (0, n - 1)
		for i in range(n):
			if C[i] != 1:
				break
			if A[l] == i:
				l += 1
			elif A[r] == i:
				r -= 1
			else:
				break
		a0 = min(C)
		k = min(i + 1, n - 1) if C[i] else i
		ans = str(a0) + '0' * (n - k - 1) + '1' * k
		yield ans
t = int(input())
ans = gift()
print(*ans, sep='\n')


import sys
input = sys.stdin.readline

def check(A):
	LEN = len(A)
	USE = [0] * (LEN + 1)
	for a in A:
		USE[a] += 1
	flag = 1
	OK = 1 << 30
	for i in range(1, LEN + 1):
		if USE[i] != 1:
			flag = 0
			OK = min(OK, i)
	for i in range(1, LEN - 1):
		if A[i - 1] >= A[i] and A[i] <= A[i + 1]:
			OK = min(OK, A[i])
	ANS = []
	USE = [0] * (LEN + 1)
	for a in A:
		if USE[a] == 0 and a <= OK:
			ANS.append(a)
			USE[a] = 1
	return (flag, ANS)
t = int(input())
for tests in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	ANS = ['0'] * n
	(f, B) = check(A)
	if f == 1:
		ANS[0] = '1'
	for i in range(-len(B), 0):
		ANS[i] = '1'
	print(''.join(ANS))


import sys
input = sys.stdin.buffer.readline
T = int(input())
for _ in range(T):
	(n, a) = (int(input()), list(map(int, input().split())))
	p1 = 1 if n == len(set(a)) == max(a) else 0
	up = 1
	for u in range(n - 2, -1, -1):
		(u1, u2) = (a[u], a[u + 1])
		if u1 > u2 and (not up):
			a[u] = u2
		elif u1 < u2 and up:
			up = 0
	a.sort()
	(res, ok) = ([], 1)
	for (i, u) in enumerate(a[:n - 1]):
		if i + 1 != u:
			ok = 0
		res.append(ok)
	res.append(p1)
	print(''.join(map(str, reversed(res))))


from sys import stdin, stdout
input = stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	arr = [0 for x in range(n)]
	l = 0
	r = n - 1
	dict = {}
	for k in range(n):
		i = a[k]
		if i in dict:
			dict[i].append(k)
		else:
			dict[i] = [k]
	if 1 not in dict:
		for i in arr:
			print(i, end='')
		print()
		continue
	arr[0] = 1
	for i in range(2, n + 1):
		if i not in dict:
			break
		if len(dict[i - 1]) == 1:
			if dict[i - 1][0] == l:
				l += 1
				arr[i - 1] = 1
			elif dict[i - 1][0] == r:
				r -= 1
				arr[i - 1] = 1
			else:
				break
		else:
			break
	arr = arr[::-1]
	for i in range(1, n + 1):
		if i not in dict:
			break
	else:
		arr[0] = 1
	for i in arr:
		print(i, end='')
	print()


import math
ok = [0] * 300002
v = []
rmq = [[0 for i in range(300002)] for j in range(20)]
t = int(input())
n = 0

def check_perm():
	v.sort()
	for i in range(n + 1):
		if v[i] != i:
			return 0
	return 1

def query(l, r):
	x = math.log2(r - l + 1)
	x = int(x)
	return min(rmq[x][l], rmq[x][r - (1 << x) + 1])
while t:
	n = int(input())
	v = [0] + list(map(int, input().split()))
	for i in range(1, n + 1):
		rmq[0][i] = v[i]
	i = 1
	while 1 << i <= n:
		for j in range(1, n - (1 << i) + 1 + 1):
			rmq[i][j] = min(rmq[i - 1][j], rmq[i - 1][j + (1 << i - 1)])
		i += 1
	l = 1
	r = n
	for i in range(n):
		if query(l, r) == i + 1:
			ok[n - i] = 1
		if v[l] == i + 1:
			l += 1
		elif v[r] == i + 1:
			r -= 1
		else:
			break
	ok[1] = check_perm()
	for i in range(1, n + 1):
		print(ok[i], end='')
		ok[i] = 0
	print('')
	t -= 1


import sys
from collections import deque, Counter
readline = sys.stdin.readline
T = int(readline())
Ans = [None] * T
for qu in range(T):
	N = int(readline())
	A = list(map(int, readline().split()))
	CA = Counter(A)
	a1 = A.count(1)
	if not a1:
		Ans[qu] = ''.join(['0'] * N)
		continue
	if a1 >= 2:
		Ans[qu] = ''.join(['0'] * (N - 1) + ['1'])
		continue
	ans = [0] * N
	if len(set(A)) == N:
		ans[0] = 1
	A = deque(A)
	res = 1
	cnt = 0
	flag = 1
	while A:
		if A[-1] == res:
			A.pop()
		elif A[0] == res:
			A.popleft()
		else:
			break
		cnt += 1
		if CA[res] > 1:
			flag = 0
			break
		res += 1
	if flag and res in A:
		cnt += 1
	for i in range(cnt):
		idx = N - 1 - i
		ans[idx] = 1
	Ans[qu] = ''.join(map(str, ans))
print('\n'.join(Ans))


import sys
input = sys.stdin.readline
(T,) = map(int, input().split())
for _ in range(T):
	(N,) = map(int, input().split())
	X = [0] + list(map(int, input().split()))
	d = [0] * (N + 1)
	for (i, x) in enumerate(X):
		d[x] += 1
	vs = set(X)
	R = [0] * N
	(mn, mx) = (0, N)
	for i in range(1, N + 1):
		if X[mn] == i - 1 and d[i - 1] == 1 and (i in vs):
			mn += 1
			R[N - i] = 1
		elif X[mx] == i - 1 and d[i - 1] == 1 and (i in vs):
			mx -= 1
			R[N - i] = 1
		else:
			break
	if len(set(X)) == N + 1:
		R[0] = 1
	print(''.join((str(c) for c in R)))


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	visited = [False for i in range(n + 1)]
	i = 0
	j = n - 1
	(flag, count) = (0, 0)
	k = 1
	mini = 9999999999
	while i <= j:
		if a[i] == k:
			i += 1
			k += 1
			count += 1
		elif a[j] == k:
			j -= 1
			k += 1
			count += 1
		else:
			while i <= j:
				mini = min(mini, a[i])
				i += 1
			if mini == k:
				count += 1
			elif mini < k:
				count = mini
	for i in range(n):
		if visited[a[i]] == True:
			flag = -1
			break
		visited[a[i]] = True
	for i in range(n - count):
		if i == flag:
			print(1, end='')
		else:
			print(0, end='')
	for i in range(n - count, n):
		print(1, end='')
	print()


import sys
input = sys.stdin.readline

class Bit:

	def __init__(self, n):
		self.size = n
		self.tree = [0] * (n + 1)

	def range_sum(self, l, r):
		return self.sum(r) - self.sum(l - 1)

	def sum(self, i):
		i += 1
		s = 0
		while i > 0:
			s += self.tree[i]
			i -= i & -i
		return s

	def get(self, i):
		return self.sum(i) - self.sum(i - 1)

	def add(self, i, x):
		i += 1
		while i <= self.size:
			self.tree[i] += x
			i += i & -i

def main():
	n = int(input())
	alst = list(map(int, input().split()))
	bit1 = Bit(n + 1)
	bit2 = Bit(n + 1)
	for a in alst:
		bit1.add(a, 1)
	ans = []
	l = 0
	r = n - 1
	pos = 1
	while r != l:
		if bit1.get(pos) >= 1 and bit1.sum(pos - 1) == 0 and (bit2.sum(pos - 1) == pos - 1):
			ans.append('1')
		else:
			ans += ['0'] * (n - len(ans) - 1)
			break
		if alst[l] <= alst[r]:
			num = alst[l]
			l += 1
		else:
			num = alst[r]
			r -= 1
		bit1.add(num, -1)
		if bit2.get(num) == 0:
			bit2.add(num, 1)
		pos += 1
	lst = [i for i in range(1, n + 1)]
	alst.sort()
	for (a, b) in zip(alst, lst):
		if a != b:
			ans.append('0')
			print(''.join(ans[::-1]))
			return
	ans.append('1')
	print(''.join(ans[::-1]))
for _ in range(int(input())):
	main()


from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s = list('0' * n)
	d = defaultdict(lambda : 0)
	for i in l:
		d[i] += 1
	if len(set(l)) == n:
		s[0] = '1'
	c = 0
	ct = n - 1
	for i in range(n):
		if d[i + 1] > 0:
			s[n - i - 1] = '1'
		else:
			break
		if d[i + 1] > 1:
			break
		if l[c] == i + 1:
			c += 1
		elif l[ct] == i + 1:
			ct -= 1
		else:
			break
	print(''.join(s))


for nt in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ans = ['0'] * n
	if sorted(a) == [i for i in range(1, n + 1)]:
		ans[0] = '1'
	else:
		ans[0] = '0'
	count = [0] * n
	for i in a:
		count[i - 1] += 1
	l = 0
	r = n - 1
	curr = 1
	ind = -1
	for i in range(n):
		if count[i]:
			minn = i + 1
			break
	if min(a) == 1:
		ans[-1] = '1'
	while curr < n:
		if a[l] == curr and count[curr - 1] == 1 and (count[curr] >= 1):
			l += 1
			ans[n - 1 - curr] = '1'
		elif a[r] == curr and count[curr - 1] == 1 and (count[curr] >= 1):
			r -= 1
			ans[n - 1 - curr] = '1'
		else:
			ind = curr
			break
		curr += 1
	print(''.join(ans))


import io
import os
from collections import Counter, defaultdict, deque

class RangeQuery:

	def __init__(self, data, func=min):
		self.func = func
		self._data = _data = [list(data)]
		(i, n) = (1, len(_data[0]))
		while 2 * i <= n:
			prev = _data[-1]
			_data.append([func(prev[j], prev[j + i]) for j in range(n - 2 * i + 1)])
			i <<= 1

	def query(self, start, stop):
		depth = (stop - start).bit_length() - 1
		return self.func(self._data[depth][start], self._data[depth][stop - (1 << depth)])

	def __getitem__(self, idx):
		return self._data[0][idx]

def isPerm(C):
	return len(set(C)) == len(C) and min(C) == 1 and (max(C) == len(C))

def solveBrute(N, A):
	rmq = RangeQuery(A)
	ans = []
	for k in range(1, N + 1):
		C = []
		for i in range(N - k + 1):
			C.append(rmq.query(i, i + k))
		print(C)
		if isPerm(C):
			ans.append('1')
		else:
			ans.append('0')
	return ''.join(ans)

def solve(N, A):
	ans = ['0'] * N
	if isPerm(A):
		ans[1 - 1] = '1'
	else:
		ans[1 - 1] = '0'
	if min(A) == 1:
		ans[N - 1] = '1'
	else:
		ans[N - 1] = '0'
	rmq = RangeQuery(A)
	indices = defaultdict(list)
	for (i, x) in enumerate(A):
		indices[x].append(i)
	i = 0
	j = N - 1
	for x in range(1, N + 1):
		mnIndices = indices[x]
		if len(mnIndices) == 1 and mnIndices[0] in [i, j]:
			if mnIndices[0] == i:
				i += 1
			else:
				assert mnIndices[0] == j
				j -= 1
			ans[-x] = '1'
		elif rmq.query(i, j + 1) == x:
			ans[-x] = '1'
			break
		else:
			break
	return ''.join(ans)
DEBUG = False
if DEBUG:
	import random
	random.seed(0)
	for _ in range(10000):
		N = random.randint(1, 10)
		A = [random.randint(1, 10) for i in range(N)]
		print('tc', _, N, A)
		ans1 = solve(N, A)
		ans2 = solveBrute(N, A)
		print(ans1, ans2)
		assert ans1 == ans2
	exit()
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
TC = int(input())
for tc in range(1, TC + 1):
	(N,) = [int(x) for x in input().split()]
	A = [int(x) for x in input().split()]
	ans = solve(N, A)
	print(ans)


from collections import defaultdict as dd, deque as dq
import sys
input = sys.stdin.readline
t = int(input())
while t:
	n = int(input())
	l = list(map(int, input().split()))
	s = set(l)
	l = dq(l)
	d = dd(int)
	for i in range(n):
		d[l[i]] += 1
	res = ['0'] * n
	if d[1]:
		res[n - 1] = '1'
	curr = 1
	for i in range(n - 1, 0, -1):
		if d[curr] and d[curr - 1] == 0:
			res[i] = '1'
		else:
			break
		if l[0] == curr:
			l.popleft()
			res[i] = '1'
			d[curr] -= 1
		elif l[-1] == curr:
			l.pop()
			res[i] = '1'
			d[curr] -= 1
		curr += 1
	if len(s) == n:
		res[0] = '1'
	print(''.join(res))
	t -= 1


import sys
from copy import *
from bisect import *
from math import gcd, ceil, sqrt

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
sys.setrecursionlimit(10 ** 5)
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')
di = [[-1, 0], [1, 0], [0, 1], [0, -1]]

def string(s):
	return ''.join(s)

def fori(n):
	return [fi() for i in range(n)]

def inc(d, c, x=1):
	d[c] = d[c] + x if c in d else x

def li():
	return [int(xx) for xx in input().split()]

def fli():
	return [float(x) for x in input().split()]

def comp(a, b):
	if a > b:
		return 2
	return 2 if a == b else 0

def gi():
	return [xx for xx in input().split()]

def gtc(tc, ans):
	print('Case #' + str(tc) + ':', ans)

def cil(n, m):
	return n // m + int(n % m > 0)

def fi():
	return int(input())

def pro(a):
	return reduce(lambda a, b: a * b, a)

def swap(a, i, j):
	(a[i], a[j]) = (a[j], a[i])

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())

def gh():
	sys.stdout.flush()

def isvalid(i, j, n, m):
	return 0 <= i < n and 0 <= j < m

def bo(i):
	return ord(i) - ord('a')

def graph(n, m):
	for i in range(m):
		(x, y) = mi()
		a[x].append(y)
		a[y].append(x)
t = fi()
while t > 0:
	t -= 1
	n = fi()
	a = li()
	st = []
	pre = [n] * n
	for i in range(n):
		if len(st) == 0:
			st.append(i)
		else:
			if a[st[-1]] > a[i]:
				while len(st) and a[st[-1]] > a[i]:
					pre[st[-1]] = i
					st.pop()
			st.append(i)
	st = []
	suf = [-1] * n
	for i in range(n - 1, -1, -1):
		if len(st) == 0:
			st.append(i)
		else:
			if a[st[-1]] > a[i]:
				while len(st) and a[st[-1]] > a[i]:
					suf[st[-1]] = i
					st.pop()
			st.append(i)
	d = [0] * (n + 1)
	for i in range(n):
		d[a[i]] = max(d[a[i]], pre[i] - suf[i] - 1)
	ans = ''
	flag = [1] * (n + 1)
	pm = [n for i in range(n + 1)]
	for i in range(1, n + 1):
		pm[i] = min(pm[i - 1], d[i])
	for i in range(1, n + 1):
		if pm[n - i + 1] < i:
			flag[i] = 0
	for i in range(1, n + 1):
		print(flag[i], end='')
	print()


from sys import stdin
ip = stdin.readline
for _ in range(int(ip())):
	n = int(ip())
	a = [int(i) - 1 for i in ip().split()]
	cnt = [0] * n
	ans = [0] * n
	for i in a:
		cnt[i] += 1
	ans[0] = 0 if cnt.count(0) > 0 else 1
	ans[n - 1] = int(cnt[0] > 0)
	(l, r) = (0, n - 1)
	for i in range(1, n):
		j = i - 1
		if cnt[j] == 1 and cnt[i]:
			if a[l] == j:
				l += 1
			elif a[r] == j:
				r -= 1
			else:
				break
			ans[n - i - 1] = 1
		else:
			break
	print(*ans, sep='')


from sys import stdin
T = int(stdin.readline().strip())
for casos in range(T):
	n = int(stdin.readline().strip())
	s = list(map(int, stdin.readline().strip().split()))
	if n == 1:
		print('1')
		continue
	cnt = [0 for i in range(n + 2)]
	for i in s:
		cnt[i] += 1
	ans = '1'
	for i in range(1, n + 1):
		if cnt[i] != 1:
			ans = '0'
			break
	aux = ''
	if cnt[1] > 0:
		aux += '1'
		next = 2
		pos1 = 0
		pos2 = n - 1
		for i in range(2, n):
			if s[pos1] == i - 1 and cnt[i - 1] == 1 and (cnt[i] > 0):
				pos1 += 1
				aux += '1'
			elif s[pos2] == i - 1 and cnt[i - 1] == 1 and (cnt[i] > 0):
				pos2 -= 1
				aux += '1'
			else:
				while len(aux) < n - 1:
					aux += '0'
				break
	else:
		aux = '0' * (n - 1)
	ans += aux[::-1]
	print(ans)


import sys
input = sys.stdin.readline
t = int(input())
for you in range(t):
	n = int(input())
	l = input().split()
	li = [int(i) for i in l]
	curr = 1
	start = 0
	end = n - 1
	while start <= end:
		if li[start] == curr:
			start += 1
			curr += 1
		elif li[end] == curr:
			end -= 1
			curr += 1
		else:
			break
	ok = [0 for i in range(n)]
	for i in range(n):
		ok[li[i] - 1] += 1
	poss = 1
	for i in range(n):
		if ok[i] == 0:
			poss = 0
			break
	lol = [0 for i in range(n)]
	lol[0] = poss
	for i in range(n - curr + 1, n):
		lol[i] = 1
	done = 0
	if end < start:
		done = 1
	else:
		z = min(li[start:end + 1])
		if z == curr:
			done = 1
		else:
			done = 0
	lol[n - curr] = done
	li.sort()
	ans = n + 1
	for i in range(1, n):
		if li[i] == li[i - 1]:
			ans = li[i]
			break
	for i in range(n - ans):
		lol[i] = 0
	for i in lol:
		print(i, end='')
	print()


from collections import deque
import sys

def input():
	return sys.stdin.readline().rstrip()

def solve():
	n = int(input())
	A = list(map(int, input().split()))
	b = A.copy()
	a = deque(A)
	b.sort(reverse=True)
	good = False
	if all((b[i] == n - i for i in range(n))):
		good = True
	expected_value = 0
	ans = [0] * n
	while b:
		expected_value += 1
		value = b.pop()
		cnt = 1
		while b and b[-1] == value:
			cnt += 1
			b.pop()
		if value != expected_value:
			b.clear()
			continue
		elif value == expected_value and cnt > 1:
			ans[n - value] += 1
			b.clear()
			continue
		elif a[0] == value:
			a.popleft()
			ans[n - value] += 1
			continue
		elif a[-1] == value:
			a.pop()
			ans[n - value] += 1
			continue
		else:
			ans[n - value] += 1
			b.clear()
			continue
	if good and ans[0] == 0:
		ans[0] += 1
	res = ''.join(map(str, ans))
	print(res)
	return

def main():
	t = 1
	t = int(input())
	for i in range(t):
		solve()
	return
main()


gans = []
for _ in range(int(input())):
	n = int(input())
	u = list(map(int, input().split())) + [0]
	d = [0] * n
	for i in range(1, n):
		c = i - 1
		while u[c] >= u[i]:
			c -= d[c] + 1
		d[i] = i - c - 1
	p = [0] * n
	for i in range(n - 2, -1, -1):
		c = i + 1
		while u[c] >= u[i]:
			c += p[c] + 1
		p[i] = c - i - 1
	ans = [0] * n
	u.pop()
	s = [0] * n
	z = [0] * n
	for i in range(n):
		z[u[i] - 1] = max(z[u[i] - 1], d[i] + p[i])
		s[u[i] - 1] += 1
	for i in range(n):
		if s[i] == 0:
			break
		if i > 0:
			z[i] = min(z[i], z[i - 1])
		if z[i] + i + 1 >= n:
			ans[i] = 1
	ans.reverse()
	gans.append(''.join(map(str, ans)))
print('\n'.join(gans))


from math import *
from sys import *
from bisect import *
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	c = [0] * (n + 1)
	ans = []
	f = True
	for i in range(n):
		c[a[i]] += 1
	l = 0
	h = n - 1
	for i in range(1, n):
		if f and c[i]:
			ans.append(1)
		else:
			ans.append(0)
		if c[i] != 1:
			f = False
		elif a[l] == i:
			l += 1
		elif a[h] == i:
			h -= 1
		else:
			f = False
	f = 0
	for i in range(1, n + 1):
		if c[i] != 1:
			f = 1
			break
	if f == 1:
		ans.append(0)
	else:
		ans.append(1)
	ans = ans[::-1]
	print(*ans, sep='')


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	s = ['0' for i in range(n)]
	c = [0] * n
	for i in range(n):
		c[arr[i] - 1] += 1
	if c[0] > 0:
		s[-1] = '1'
	i = 0
	j = n - 1
	p = 1
	s[0] = '1' if len(set(arr)) == n else '0'
	while p < n:
		if (arr[i] == p or arr[j] == p) and c[p - 1] == 1 and (c[p] >= 1):
			if arr[i] == p:
				i += 1
				s[n - 1 - p] = '1'
			elif arr[j] == p:
				j -= 1
				s[n - 1 - p] = '1'
			p += 1
			continue
		break
	print(''.join(s))


from collections import deque

def readGenerator():
	while True:
		tokens = input().split(' ')
		for t in tokens:
			yield t
reader = readGenerator()

def readWord():
	return next(reader)

def readInt():
	return int(next(reader))

def readFloat():
	return float(next(reader))

def readLine():
	return input()

def createCompression(a, n, k):
	m = deque()
	res = set()
	for i in range(n):
		if len(m) > 0 and m[0][1] < i - k:
			m.popleft()
		while len(m) > 0 and m[-1][0] >= a[i]:
			m.pop()
		m.append((a[i], i))
		if i - k > -1:
			res.add(m[0][0])
	return len(res) == n - k and max(res) == n - k

def solve(n, a):
	if n == 1:
		return '1' if a[0] == 1 else '0'
	if createCompression(a, n, 1) and createCompression(a, n, 0):
		return '1' * n
	if not createCompression(a, n, n - 1):
		return '0' * n
	s = '1' if createCompression(a, n, 0) else '0'
	l = 0
	r = n - 1
	while r - l > 1:
		mid = (r + l) // 2
		if createCompression(a, n, mid):
			r = mid
		else:
			l = mid
	if createCompression(a, n, l):
		return s + '0' * (l - 1) + '1' * (n - l)
	return s + '0' * (r - 1) + '1' * (n - r)
t = readInt()
for _ in range(t):
	n = readInt()
	a = [readInt() for _ in range(n)]
	print(solve(n, a))


def is_permutatio3n(l):
	se = set()
	n = len(l)
	for e in l:
		if e in se or e > n:
			return False
		se.add(e)
	return True

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		is_permutation = True
		d = {}
		M = 0
		for e in a:
			M = max(M, e)
			if e in d:
				is_permutation = False
				d[e] += 1
			else:
				d[e] = 1
		if M > n:
			is_permutation = False
		left = 0
		right = n - 1
		z = 0
		last_work = 0
		while z < n:
			z += 1
			if z not in d:
				break
			last_work = z
			if d[z] > 1:
				break
			else:
				last_work = z
				if a[left] == z:
					left += 1
				elif a[right] == z:
					right -= 1
				else:
					break
		last_work = min(last_work, n - 1)
		l = [str(int(is_permutation))]
		for i in range(1, n - last_work):
			l.append('0')
		for j in range(n - last_work, n):
			l.append('1')
		print(''.join(l))
main()


from bisect import *
from collections import *
from math import gcd, ceil, sqrt, floor, inf
from heapq import *
from itertools import *
from operator import add, mul, sub, xor, truediv, floordiv
from functools import *
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc
farr = [1]
ifa = []

def fact(x, mod=0):
	if mod:
		while x >= len(farr):
			farr.append(farr[-1] * len(farr) % mod)
	else:
		while x >= len(farr):
			farr.append(farr[-1] * len(farr))
	return farr[x]

def ifact(x, mod):
	global ifa
	ifa.append(pow(farr[-1], mod - 2, mod))
	for i in range(x, 0, -1):
		ifa.append(ifa[-1] * i % mod)
	ifa = ifa[::-1]

def per(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return fact(i) // fact(i - j)
	return farr[i] * ifa[i - j] % mod

def com(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return per(i, j) // fact(j)
	return per(i, j, mod) * ifa[j] % mod

def catalan(n):
	return com(2 * n, n) // (n + 1)

def isprime(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True

def lowbit(n):
	return n & -n

def inverse(a, m):
	a %= m
	if a <= 1:
		return a
	return (1 - inverse(m, a) * m) // a % m

class BIT:

	def __init__(self, arr):
		self.arr = arr
		self.n = len(arr) - 1

	def update(self, x, v):
		while x <= self.n:
			self.arr[x] += v
			x += x & -x

	def query(self, x):
		ans = 0
		while x:
			ans += self.arr[x]
			x &= x - 1
		return ans

class DSU:

	def __init__(self, n):
		self.c = [-1] * n

	def same(self, x, y):
		return self.find(x) == self.find(y)

	def find(self, x):
		if self.c[x] < 0:
			return x
		self.c[x] = self.find(self.c[x])
		return self.c[x]

	def union(self, u, v):
		(u, v) = (self.find(u), self.find(v))
		if u == v:
			return False
		if self.c[u] < self.c[v]:
			(u, v) = (v, u)
		self.c[u] += self.c[v]
		self.c[v] = u
		return True

	def size(self, x):
		return -self.c[self.find(x)]

class UFS:

	def __init__(self, n):
		self.parent = [i for i in range(n)]
		self.ranks = [0] * n

	def find(self, x):
		if x != self.parent[x]:
			self.parent[x] = self.find(self.parent[x])
		return self.parent[x]

	def union(self, u, v):
		(pu, pv) = (self.find(u), self.find(v))
		if pu == pv:
			return False
		if self.ranks[pu] >= self.ranks[pv]:
			self.parent[pv] = pu
			if self.ranks[pv] == self.ranks[pu]:
				self.ranks[pu] += 1
		else:
			self.parent[pu] = pv

def Prime(n):
	c = 0
	prime = []
	flag = [0] * (n + 1)
	for i in range(2, n + 1):
		if not flag[i]:
			prime.append(i)
			c += 1
		for j in range(c):
			if i * prime[j] > n:
				break
			flag[i * prime[j]] = prime[j]
			if i % prime[j] == 0:
				break
	return flag

def dij(s, graph):
	d = {}
	d[s] = 0
	heap = [(0, s)]
	seen = set()
	while heap:
		(dis, u) = heappop(heap)
		if u in seen:
			continue
		for v in graph[u]:
			if v not in d or d[v] > d[u] + graph[u][v]:
				d[v] = d[u] + graph[u][v]
				heappush(heap, (d[v], v))
	return d

def GP(it):
	return [[ch, len(list(g))] for (ch, g) in groupby(it)]

class DLN:

	def __init__(self, val):
		self.val = val
		self.pre = None
		self.next = None

def nb(i, j):
	for (ni, nj) in [[i + 1, j], [i - 1, j], [i, j - 1], [i, j + 1]]:
		if 0 <= ni < n and 0 <= nj < m:
			yield (ni, nj)

@bootstrap
def gdfs(r, p):
	if len(g[r]) == 1 and p != -1:
		yield None
	for ch in g[r]:
		if ch != p:
			yield gdfs(ch, r)
	yield None
t = N()
for i in range(t):
	n = N()
	a = RLL()
	ans = ['0'] * n
	s = sorted(a)
	if s == list(range(1, n + 1)):
		ans[0] = '1'
	l = 0
	r = n - 1
	i = n - 2
	if s[0] == 1:
		ans[-1] = '1'
	while i > 0:
		if a[l] == n - 1 - i or a[r] == n - 1 - i:
			if s[n - 1 - i] == n - i:
				ans[i] = '1'
				if a[l] == n - 1 - i:
					l += 1
				else:
					r -= 1
				i -= 1
			else:
				break
		else:
			break
	ans = ''.join(ans)
	print(ans)


def checker(z, k):
	de = deque()
	for i in range(k):
		if i == 0:
			de.append(i)
		else:
			while len(de) and z[i] <= z[de[-1]]:
				de.pop()
			de.append(i)
	ans = []
	for i in range(k, len(z)):
		inter = i - k
		while de[0] < inter:
			de.popleft()
		t = de[0]
		ans.append(z[t])
		while len(de) and z[i] <= z[de[-1]]:
			de.pop()
		de.append(i)
	while de[0] < len(z) - k:
		de.popleft()
	t = de[0]
	ans.append(z[t])
	ans.sort()
	for i in range(len(ans)):
		if ans[i] != i + 1:
			return 0
	return 1
from collections import *
a = int(input())
for i in range(a):
	s = int(input())
	z = list(map(int, input().split()))
	al = defaultdict(int)
	for i in range(len(z)):
		al[z[i]] += 1
	ans = [0 for i in range(len(z))]
	l = 0
	r = s - 1
	save = -1
	for i in range(1, s + 1):
		if al[i] == 0:
			save = i - 1
			break
		elif al[i] > 1:
			save = i
			break
		save = i
	compression = len(z)
	for i in range(1, save + 1):
		if z[l] == i and l <= r:
			ans[len(z) - i] = 1
			l += 1
			continue
		elif z[r] == i and l <= r:
			ans[len(z) - i] = 1
			r -= 1
			continue
		else:
			compression = len(z) - i + 1
			break
	z.sort()
	flag = 0
	for i in range(len(z)):
		if z[i] != i + 1:
			flag = 1
			break
	if flag == 0:
		ans[0] = 1
	if checker(z, compression) == 1:
		ans[compression - 1] = 1
	for i in range(len(ans)):
		print(ans[i], end='')
	print('')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline()

def RL():
	return map(int, sys.stdin.readline().split())

def RLL():
	return list(map(int, sys.stdin.readline().split()))

def N():
	return int(input())

def print_list(l):
	print(' '.join(map(str, l)))
for _ in range(N()):
	n = N()
	a = RLL()
	stack = [(-1, -1)]
	m = [0] * (n + 1)
	for i in range(n):
		v = a[i]
		while stack[-1][0] > v:
			(t, _) = stack.pop()
			m[t] = max(m[t], i - stack[-1][1] - 1)
		stack.append((v, i))
	while len(stack) > 1:
		(v, _) = stack.pop()
		m[v] = max(m[v], n - stack[-1][1] - 1)
	res = ['1'] * n
	r = n + 10
	for i in range(1, n + 1):
		for j in range(m[i] + 1, min(r, n - i + 2)):
			res[j - 1] = '0'
		r = min(r, m[i] + 1)
	print(''.join(res))


import sys
import math, bisect, operator
(inf, m) = (float('inf'), 10 ** 9 + 7)
sys.setrecursionlimit(10 ** 5)
from itertools import groupby, accumulate
from heapq import heapify, heappop, heappush
from collections import deque, Counter, defaultdict
I = lambda : int(sys.stdin.readline())
neo = lambda : map(int, sys.stdin.readline().split())
Neo = lambda : list(map(int, sys.stdin.readline().split()))
for _ in range(I()):
	n = I()
	Ans = list('0' * n)
	A = Neo()
	d = Counter(A)
	dq = deque(A)
	i = 1
	j = n - 1
	while d:
		if not d.get(i, 0):
			break
		Ans[j] = '1'
		if dq[0] == i:
			dq.popleft()
		elif dq[-1] == i:
			dq.pop()
		else:
			break
		if d.get(i, 0) > 1:
			break
		i += 1
		j -= 1
	if len(set(A)) == n:
		Ans[0] = '1'
	print(''.join(Ans))


import sys
import math
input = sys.stdin.readline

def pi():
	return int(input())

def pl():
	return int(input(), 16)

def ti():
	return list(map(int, input().split()))

def ts():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def main():
	D()
count = [0 for i in range(300005)]

def D():
	t = pi()
	while t:
		t -= 1
		n = pi()
		a = ti()
		res = [0 for i in range(n)]
		mn = 9999999999
		mx = 0
		for i in range(n):
			mn = min(mn, a[i])
			mx = max(mx, a[i])
		for i in range(mx + 1):
			count[i] = 0
		f = 0
		for i in range(n):
			count[a[i]] += 1
			if count[a[i]] > 1:
				f = 1
		if f != 1:
			res[0] = 1
		l = 0
		r = n - 1
		for i in range(n - 1, -1, -1):
			nxt = n - i
			if count[nxt] != 0:
				res[i] = 1
			count[nxt] -= 1
			if count[nxt] == 0 and ((a[l] == nxt or a[r] == nxt) and count[nxt + 1] != 0):
				if a[l] == nxt:
					l += 1
				if a[r] == nxt:
					r -= 1
				continue
			break
		print(*res, sep='')
main()


from sys import stdin
input = stdin.readline
q = int(input())
for _ in range(q):
	n = int(input())
	l = list(map(int, input().split()))
	ile = [0] * (n + 1)
	for i in l:
		ile[i] += 1
	lewy = 0
	prawy = n - 1
	step = 1
	while True:
		if lewy == prawy:
			break
		if l[lewy] != step and l[prawy] != step:
			break
		elif l[lewy] == step:
			lewy += 1
		else:
			prawy -= 1
		step += 1
	poss = step - 1
	if ile[poss + 1] > 0:
		poss += 1
	ogr = 10 ** 9
	for i in range(1, n + 1):
		if ile[i] > 1:
			ogr = i
			break
	poss = min(ogr, poss)
	word = (n - poss) * '0' + poss * '1'
	if ile == [0] + [1] * n:
		print('1' + word[1:])
	else:
		print(word)


import sys, os, io
input = sys.stdin.readline
from collections import Counter
T = int(input())

def solve(n, A):
	cnts = Counter(A)
	if cnts[1] == 1:
		ans = [1]
	elif cnts[1] == 0:
		ans = [0] * n
		return ans
	else:
		ans = [0] * (n - 1) + [1]
		return ans
	if n == 1:
		return ans
	lis = []
	left = 0
	right = n - 1
	for _ in range(n):
		if A[left] <= A[right]:
			lis.append(A[left])
			left += 1
		else:
			lis.append(A[right])
			right -= 1
	check = [0] * (n + 1)
	max_a = 0
	for i in range(n - 2):
		check[lis[i]] += 1
		max_a = max(max_a, lis[i])
		if max_a == i + 1 and cnts[i + 1] == 1 and (cnts[i + 2] > 0):
			ans.append(1)
		else:
			p = len(ans)
			for _ in range(n - 1 - p):
				ans.append(0)
			break
	if len(set(A)) == n and lis[-1] == n:
		ans.append(1)
	else:
		ans.append(0)
	ans = ans[::-1]
	return ans
for t in range(T):
	n = int(input())
	A = list(map(int, input().split()))
	print(''.join(map(str, solve(n, A))))


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	ans = ['0'] * n
	a = list(map(int, input().split()))
	if sorted(a) == list(range(1, n + 1)):
		ans[0] = '1'
	c = [0] * (n + 1)
	ind = [0] * (n + 1)
	for i in range(n):
		c[a[i]] += 1
		ind[a[i]] = i
	(s, e) = (0, n - 1)
	pos = 1
	for i in range(1, n + 1):
		if i == 1 and c[i] or (c[i] and (pos == s - 1 or pos == e + 1)):
			ans[n - i] = '1'
			pos = ind[i]
			if pos == s:
				s += 1
			else:
				e -= 1
			if c[i] > 1:
				break
		else:
			break
	print(''.join(ans))


from collections import Counter

def solve():
	n = int(input())
	arr = [int(x) for x in input().split()]
	arr_count = Counter(arr)
	is_perm = '1'
	for i in range(1, n + 1):
		if arr_count[i] != 1:
			is_perm = '0'
	curr_l = 0
	curr_r = n - 1
	x___pos = [set() for _ in range(n + 1)]
	for (i, x) in enumerate(arr):
		x___pos[x].add(i)
	for x in range(1, n + 1):
		pos = x___pos[x]
		if len(pos) == 0:
			ans = ['1' for _ in range(x - 1)] + ['0' for _ in range(n)]
			ans = ans[:n - 1]
			ans.append(is_perm)
			ans.reverse()
			print(''.join(ans))
			return
		if len(pos) > 1:
			ans = ['1' for _ in range(x)] + ['0' for _ in range(n)]
			ans = ans[:n - 1]
			ans.append(is_perm)
			ans.reverse()
			print(''.join(ans))
			return
		pos = pos.pop()
		if pos != curr_l and pos != curr_r:
			ans = ['1' for _ in range(x)] + ['0' for _ in range(n)]
			ans = ans[:n - 1]
			ans.append(is_perm)
			ans.reverse()
			print(''.join(ans))
			return
		if pos == curr_l:
			curr_l += 1
		else:
			curr_r -= 1
	ans = [is_perm] + ['1' for _ in range(n - 1)]
	print(''.join(ans))
for _ in range(int(input())):
	solve()


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from bisect import insort
from collections import Counter
from collections import deque
from heapq import heappush, heappop, heapify
from itertools import permutations, combinations
mod = int(1000000000.0) + 7
mod = 998244353
ip = lambda : int(stdin.readline())
inp = lambda : map(int, stdin.readline().split())
ips = lambda : stdin.readline().rstrip()
out = lambda x: stdout.write(str(x) + '\n')

def check(ch):
	ch.sort()
	ct = 1
	flag = True
	for i in range(len(ch)):
		if i + 1 == ch[i]:
			pass
		else:
			flag = False
			break
	return flag
t = ip()
for _ in range(t):
	n = ip()
	arr = list(inp())
	tree = sorted(list(arr))
	tree = deque(tree)
	ans = [None] * n
	st = 0
	end = n - 1
	i = 0
	if check(list(arr)):
		ans[n - 1] = '1'
	while i < n - 1:
		if arr[st] == i + 1:
			st += 1
			i += 1
			tree.popleft()
		elif arr[end] == i + 1:
			end -= 1
			i += 1
			tree.popleft()
		else:
			break
		val = tree[0]
		if val == i + 1:
			ans[i] = '1'
		else:
			break
	ans = ans[::-1]
	if min(arr) == 1:
		ans[n - 1] = '1'
	for i in range(n):
		if ans[i] == None:
			ans[i] = '0'
	ans = ''.join(ans)
	out(ans)


import sys

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for k in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** (-10)

class BIT:

	def __init__(self, n):
		self.n = n
		n += 1
		nv = 1
		while nv < n:
			nv *= 2
		self.size = nv
		self.tree = [0] * nv

	def sum(self, i):
		s = 0
		i += 1
		while i > 0:
			s += self.tree[i - 1]
			i -= i & -i
		return s

	def add(self, i, x):
		i += 1
		while i <= self.size:
			self.tree[i - 1] += x
			i += i & -i

	def query(self, l, r):
		return self.sum(r - 1) - self.sum(l - 1)

	def get(self, i):
		return self.query(i, i + 1)

	def update(self, i, x):
		self.add(i, x - self.get(i))

	def print(self):
		for i in range(self.n):
			print(self.get(i), end=' ')
		print()

	def bisearch_fore(self, l, r, x):
		l_sm = self.sum(l - 1)
		ok = r + 1
		ng = l - 1
		while ng + 1 < ok:
			mid = (ok + ng) // 2
			if self.sum(mid) - l_sm >= x:
				ok = mid
			else:
				ng = mid
		if ok != r + 1:
			return ok
		else:
			return -1

	def bisearch_back(self, l, r, x):
		r_sm = self.sum(r)
		ok = l - 1
		ng = r + 1
		while ok + 1 < ng:
			mid = (ok + ng) // 2
			if r_sm - self.sum(mid - 1) >= x:
				ok = mid
			else:
				ng = mid
		if ok != l - 1:
			return ok
		else:
			return -1
for _ in range(INT()):
	N = INT()
	A = [a - 1 for a in LIST()]
	C = [0] * N
	B = [[] for i in range(N)]
	for i in range(N):
		C[A[i]] += 1
		B[A[i]].append(i)
	bit = BIT(N)
	ans = [0] * N
	for a in range(N):
		if not C[a]:
			break
		ln = N - a - 1
		se = set()
		for i in B[a]:
			l = bit.bisearch_back(max(i - ln, 0), i - 1, 1)
			if l == -1:
				l = max(i - ln, 0)
			else:
				l += 1
			r = bit.bisearch_fore(i + 1, min(i + ln, N - 1), 1)
			if r == -1:
				r = min(i + ln, N - 1)
			else:
				r -= 1
			if r - l == ln:
				se.add((l, r))
			bit.add(i, 1)
		if len(se) != 1:
			break
		ans[ln] = 1
	if len(set(A)) == N:
		ans[0] = 1
	print(''.join(map(str, ans)))


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def findMin(count, start):
	for i in range(start, n):
		if count[i] != 0:
			return (i + 1, i)
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	count = [0] * n
	for i in range(n):
		count[arr[i] - 1] += 1
	ans = ['0'] * n
	if min(count) == max(count):
		ans[0] = '1'
	if min(arr) == 1:
		ans[-1] = '1'
	l = 0
	r = n - 1
	index = -1
	start = 0
	for i in range(n - 1):
		if arr[l] == i + 1:
			count[arr[l] - 1] -= 1
			l += 1
			(x, start) = findMin(count, start)
			if x == i + 2:
				continue
			else:
				index = i + 2
				break
		elif arr[r] == i + 1:
			count[arr[r] - 1] -= 1
			r -= 1
			(x, start) = findMin(count, start)
			if x == i + 2:
				continue
			else:
				index = i + 2
				break
		elif i > 0:
			index = i + 2
			break
		else:
			index = i + 1
			break
	if index != -1:
		for i in range(n - index + 1, n):
			ans[i] = '1'
	else:
		for i in range(1, n):
			ans[i] = '1'
	print(''.join(ans))


from collections import defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	d = defaultdict(list)
	ans = []
	for i in range(n):
		d[a[i]].append(i)
		ans.append(1)
	up = n - 1
	down = 0
	flag = False
	for k in range(1, n):
		if len(d[k]) == 0 or flag:
			flag = True
			if k == 1:
				ans[n - 1] = 0
			ans[n - k] = 0
			continue
		if k == 1:
			if len(d[2]) == 0 or len(d[1]) > 1:
				ans[n - 2] = 0
			elif a[up] == k:
				up -= 1
			elif a[down] == k:
				down += 1
			else:
				ans[n - 2] = 0
		elif ans[n - k] == 1:
			if min(a[up], a[down]) == k:
				if a[up] == k:
					up -= 1
				elif a[down] == k:
					down += 1
			else:
				ans[n - k - 1] = 0
		else:
			ans[n - k - 1] = 0
		if len(d[k]) > 1:
			flag = True
	if flag or len(d[n]) == 0:
		ans[0] = 0
	else:
		ans[0] = 1
	for i in range(n):
		print(ans[i], end='')
	print()


from sys import stdin
from math import inf
from collections import deque as deq
input = lambda : stdin.readline().strip()
ipnut = input
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	s = {}
	d = deq()
	for i in a:
		s[i] = s.get(i, 0) + 1
		d.append(i)
	ans = [0] * n
	for i in range(n - 1):
		f = 0
		if i == 0:
			ans[i] = int(1 in s)
			f = ans[i]
		elif ans[i - 1] == 1 and s[i] == 1 and (i + 1 in s):
			first = d.popleft()
			last = d.pop()
			f = 1
			ans[i] = 1
			if first == i:
				d.append(last)
			elif last == i:
				d.appendleft(first)
			else:
				ans[i] = 0
		if ans[i] == 0:
			break
	if len(s) == n and max(a) == n:
		ans[-1] = 1
	print(''.join(list(map(str, ans))[::-1]))


import sys
input = lambda : sys.stdin.readline().rstrip()
T = int(input())
for _ in range(T):
	N = int(input())
	A = [int(a) - 1 for a in input().split()]
	C = [0] * N
	for a in A:
		C[a] += 1
	(l, r) = (0, N - 1)
	for i in range(N):
		if C[i] != 1:
			break
		if A[l] == i:
			l += 1
		elif A[r] == i:
			r -= 1
		else:
			break
	i = min(i, N - 1)
	a0 = min(C)
	k = min(i + 1, N - 1) if C[i] else i
	ans = str(a0) + '0' * (N - k - 1) + '1' * k
	print(ans)


import sys
input = sys.stdin.buffer.readline
import math

class RMQMIN:

	def __init__(self, arr):
		self.arr = arr
		MAXN = len(arr)
		K = int(math.log2(MAXN)) + 1
		self.lookup = [[0 for _ in range(K + 1)] for __ in range(MAXN)]
		self.buildSparseTable()

	def buildSparseTable(self):
		n = len(self.arr)
		for i in range(0, n):
			self.lookup[i][0] = self.arr[i]
		j = 1
		while 1 << j <= n:
			i = 0
			while i + (1 << j) - 1 < n:
				if self.lookup[i][j - 1] < self.lookup[i + (1 << j - 1)][j - 1]:
					self.lookup[i][j] = self.lookup[i][j - 1]
				else:
					self.lookup[i][j] = self.lookup[i + (1 << j - 1)][j - 1]
				i += 1
			j += 1

	def query(self, L, R):
		j = int(math.log2(R - L + 1))
		if self.lookup[L][j] <= self.lookup[R - (1 << j) + 1][j]:
			return self.lookup[L][j]
		else:
			return self.lookup[R - (1 << j) + 1][j]
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	ans = [0 for _ in range(n + 1)]
	if sorted(a) == list(range(1, n + 1)):
		ans[1] = 1
	rmq = RMQMIN(a)
	l = 0
	r = n - 1
	if rmq.query(l, r) == 1:
		ans[n] = 1
	k = n - 1
	smallest = 1
	while k > 1:
		if a[l] == smallest and rmq.query(l + 1, r) == smallest + 1:
			l += 1
			smallest += 1
			ans[k] = 1
			k -= 1
		elif a[r] == smallest and rmq.query(l, r - 1) == smallest + 1:
			r -= 1
			smallest += 1
			ans[k] = 1
			k -= 1
		else:
			break
	ans2 = []
	for i in range(1, n + 1):
		ans2.append(str(ans[i]))
	print(''.join(ans2))


class SortedList:

	def __init__(self, iterable=[], _load=200):
		values = sorted(iterable)
		self._len = _len = len(values)
		self._load = _load
		self._lists = _lists = [values[i:i + _load] for i in range(0, _len, _load)]
		self._list_lens = [len(_list) for _list in _lists]
		self._mins = [_list[0] for _list in _lists]
		self._fen_tree = []
		self._rebuild = True

	def _fen_build(self):
		self._fen_tree[:] = self._list_lens
		_fen_tree = self._fen_tree
		for i in range(len(_fen_tree)):
			if i | i + 1 < len(_fen_tree):
				_fen_tree[i | i + 1] += _fen_tree[i]
		self._rebuild = False

	def _fen_update(self, index, value):
		if not self._rebuild:
			_fen_tree = self._fen_tree
			while index < len(_fen_tree):
				_fen_tree[index] += value
				index |= index + 1

	def _fen_query(self, end):
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		x = 0
		while end:
			x += _fen_tree[end - 1]
			end &= end - 1
		return x

	def _fen_findkth(self, k):
		_list_lens = self._list_lens
		if k < _list_lens[0]:
			return (0, k)
		if k >= self._len - _list_lens[-1]:
			return (len(_list_lens) - 1, k + _list_lens[-1] - self._len)
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		idx = -1
		for d in reversed(range(len(_fen_tree).bit_length())):
			right_idx = idx + (1 << d)
			if right_idx < len(_fen_tree) and k >= _fen_tree[right_idx]:
				idx = right_idx
				k -= _fen_tree[idx]
		return (idx + 1, k)

	def _delete(self, pos, idx):
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len -= 1
		self._fen_update(pos, -1)
		del _lists[pos][idx]
		_list_lens[pos] -= 1
		if _list_lens[pos]:
			_mins[pos] = _lists[pos][0]
		else:
			del _lists[pos]
			del _list_lens[pos]
			del _mins[pos]
			self._rebuild = True

	def _loc_left(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(lo, pos) = (-1, len(_lists) - 1)
		while lo + 1 < pos:
			mi = lo + pos >> 1
			if value <= _mins[mi]:
				pos = mi
			else:
				lo = mi
		if pos and value <= _lists[pos - 1][-1]:
			pos -= 1
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value <= _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def _loc_right(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(pos, hi) = (0, len(_lists))
		while pos + 1 < hi:
			mi = pos + hi >> 1
			if value < _mins[mi]:
				hi = mi
			else:
				pos = mi
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value < _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def add(self, value):
		_load = self._load
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len += 1
		if _lists:
			(pos, idx) = self._loc_right(value)
			self._fen_update(pos, 1)
			_list = _lists[pos]
			_list.insert(idx, value)
			_list_lens[pos] += 1
			_mins[pos] = _list[0]
			if _load + _load < len(_list):
				_lists.insert(pos + 1, _list[_load:])
				_list_lens.insert(pos + 1, len(_list) - _load)
				_mins.insert(pos + 1, _list[_load])
				_list_lens[pos] = _load
				del _list[_load:]
				self._rebuild = True
		else:
			_lists.append([value])
			_mins.append(value)
			_list_lens.append(1)
			self._rebuild = True

	def discard(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_right(value)
			if idx and _lists[pos][idx - 1] == value:
				self._delete(pos, idx - 1)

	def remove(self, value):
		_len = self._len
		self.discard(value)
		if _len == self._len:
			raise ValueError('{0!r} not in list'.format(value))

	def pop(self, index=-1):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		value = self._lists[pos][idx]
		self._delete(pos, idx)
		return value

	def bisect_left(self, value):
		(pos, idx) = self._loc_left(value)
		return self._fen_query(pos) + idx

	def bisect_right(self, value):
		(pos, idx) = self._loc_right(value)
		return self._fen_query(pos) + idx

	def count(self, value):
		return self.bisect_right(value) - self.bisect_left(value)

	def __len__(self):
		return self._len

	def __getitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		return self._lists[pos][idx]

	def __delitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		self._delete(pos, idx)

	def __contains__(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_left(value)
			return idx < len(_lists[pos]) and _lists[pos][idx] == value
		return False

	def __iter__(self):
		return (value for _list in self._lists for value in _list)

	def __reversed__(self):
		return (value for _list in reversed(self._lists) for value in reversed(_list))

	def __repr__(self):
		return 'SortedList({0})'.format(list(self))
import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = [(a[i], i) for i in range(n)]
	b.sort()
	sl = SortedList()
	mem = [0] * n
	for (v, i) in b:
		ind = sl.bisect_left(i)
		if ind > 0:
			lo = sl[ind - 1] + 1
		else:
			lo = 0
		if ind < len(sl):
			hi = sl[ind] - 1
		else:
			hi = n - 1
		mem[v - 1] = max(mem[v - 1], hi - lo + 1)
		sl.add(i)
	out = []
	small = n + 12
	for i in range(n):
		small = min(small, mem[i])
		if small < n - i:
			out.append('0')
		else:
			out.append('1')
	print(''.join(out)[::-1])


def solve(n, arr):
	if n == 1:
		return ['1']
	ans = ['0' for i in range(n)]
	pos = [set() for i in range(n + 1)]
	for (i, a) in enumerate(arr):
		pos[a].add(i)
	start = 0
	end = n - 1
	for a in range(1, n + 1):
		if not pos[a]:
			return ans
		b1 = start in pos[a]
		b2 = end in pos[a]
		ans[n - a] = '1'
		if len(pos[a]) >= 2:
			return ans
		if b1:
			start += 1
		elif b2:
			end -= 1
		else:
			for i in range(1, n + 1):
				if not len(pos[i]) == 1:
					return ans
			ans[0] = '1'
			return ans
	return ans
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	print(''.join(solve(n, arr)))


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right
import time
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import defaultdict as dd, deque as dq, Counter as dc
import math, string
start_time = time.time()

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())

def getMat(n):
	return [getInts() for _ in range(n)]

def isInt(s):
	return '0' <= s[0] <= '9'
MOD = 998244353

def solve():
	N = getInt()
	A = getInts()
	set_A = set(A)
	c = dc(A)
	flag = len(set_A) == N
	A = dq(A)
	D = dd(set)
	ans = []
	for i in range(1, N):
		if i not in set_A:
			while len(ans) < N:
				ans.append(0)
			ans.reverse()
			print(*ans, sep='')
			return
		if i == 1:
			ans.append(1)
			if c[i] > 1:
				while len(ans) < N:
					ans.append(0)
				ans.reverse()
				print(*ans, sep='')
				return
			continue
		if A[0] != i - 1 and A[-1] != i - 1:
			while len(ans) < N - 1:
				ans.append(0)
			if flag:
				ans.append(1)
			else:
				ans.append(0)
			ans.reverse()
			print(*ans, sep='')
			return
		if A[0] == i - 1:
			A.popleft()
		else:
			A.pop()
		ans.append(1)
		if c[i] > 1:
			while len(ans) < N:
				ans.append(0)
			ans.reverse()
			print(*ans, sep='')
			return
	if len(ans) < N:
		if flag:
			ans.append(1)
		else:
			ans.append(0)
	ans.reverse()
	print(*ans, sep='')
	return
for _ in range(getInt()):
	solve()


import os
import sys
from io import BytesIO, IOBase
from collections import deque
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import typing

def _ceil_pow2(n: int) -> int:
	x = 0
	while 1 << x < n:
		x += 1
	return x

def _bsf(n: int) -> int:
	x = 0
	while n % 2 == 0:
		x += 1
		n //= 2
	return x

class SegTree:

	def __init__(self, op: typing.Callable[[typing.Any, typing.Any], typing.Any], e: typing.Any, v: typing.Union[int, typing.List[typing.Any]]) -> None:
		self._op = op
		self._e = e
		if isinstance(v, int):
			v = [e] * v
		self._n = len(v)
		self._log = _ceil_pow2(self._n)
		self._size = 1 << self._log
		self._d = [e] * (2 * self._size)
		for i in range(self._n):
			self._d[self._size + i] = v[i]
		for i in range(self._size - 1, 0, -1):
			self._update(i)

	def set(self, p: int, x: typing.Any) -> None:
		assert 0 <= p < self._n
		p += self._size
		self._d[p] = x
		for i in range(1, self._log + 1):
			self._update(p >> i)

	def get(self, p: int) -> typing.Any:
		assert 0 <= p < self._n
		return self._d[p + self._size]

	def prod(self, left: int, right: int) -> typing.Any:
		assert 0 <= left <= right <= self._n
		sml = self._e
		smr = self._e
		left += self._size
		right += self._size
		while left < right:
			if left & 1:
				sml = self._op(sml, self._d[left])
				left += 1
			if right & 1:
				right -= 1
				smr = self._op(self._d[right], smr)
			left >>= 1
			right >>= 1
		return self._op(sml, smr)

	def all_prod(self) -> typing.Any:
		return self._d[1]

	def max_right(self, left: int, f: typing.Callable[[typing.Any], bool]) -> int:
		assert 0 <= left <= self._n
		assert f(self._e)
		if left == self._n:
			return self._n
		left += self._size
		sm = self._e
		first = True
		while first or left & -left != left:
			first = False
			while left % 2 == 0:
				left >>= 1
			if not f(self._op(sm, self._d[left])):
				while left < self._size:
					left *= 2
					if f(self._op(sm, self._d[left])):
						sm = self._op(sm, self._d[left])
						left += 1
				return left - self._size
			sm = self._op(sm, self._d[left])
			left += 1
		return self._n

	def min_left(self, right: int, f: typing.Callable[[typing.Any], bool]) -> int:
		assert 0 <= right <= self._n
		assert f(self._e)
		if right == 0:
			return 0
		right += self._size
		sm = self._e
		first = True
		while first or right & -right != right:
			first = False
			right -= 1
			while right > 1 and right % 2:
				right >>= 1
			if not f(self._op(self._d[right], sm)):
				while right < self._size:
					right = 2 * right + 1
					if f(self._op(self._d[right], sm)):
						sm = self._op(self._d[right], sm)
						right -= 1
				return right + 1 - self._size
			sm = self._op(self._d[right], sm)
		return 0

	def _update(self, k: int) -> None:
		self._d[k] = self._op(self._d[2 * k], self._d[2 * k + 1])
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = [-1] * n
	segtree = SegTree(max, -1, b)
	survival1 = [0] * n
	for i in range(n):
		survival1[i] = i
	for i in range(n):
		k = segtree.prod(0, a[i] - 1)
		if k != -1:
			survival1[i] = min(survival1[i], i - k - 1)
		segtree.set(a[i] - 1, i)
	b = [10 ** 6] * n
	segtree = SegTree(min, 10 ** 6, b)
	survival2 = [0] * n
	for i in range(n):
		survival2[i] = n - i - 1
	for i in range(n - 1, -1, -1):
		k = segtree.prod(0, a[i] - 1)
		if k != -1:
			survival2[i] = min(survival2[i], k - i - 1)
		segtree.set(a[i] - 1, i)
	survival = [0] * n
	for i in range(n):
		survival[i] = survival1[i] + survival2[i]
	ans = []
	survival3 = [-10 ** 6] * n
	for i in range(n):
		k = a[i]
		survival3[k - 1] = max(survival[i], survival3[k - 1])
	ans = []
	curr = 0
	for i in range(n):
		curr = min(curr, survival3[i] - n + i)
		curr += 1
		if curr < 0:
			ans.append('0')
		else:
			ans.append('1')
	ans.reverse()
	print(''.join(ans))


import sys, io, os
BUFSIZE = 8192

class FastIO(io.IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = io.BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(io.IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from random import randint

def xorshift(seed=123456789):
	y = seed
	mask = (1 << 64) - 1

	def randint():
		nonlocal y
		y ^= y << 7 & mask
		y ^= y >> 9
		return y
	return randint
randint = xorshift(randint(0, 1234578532345))
Hash = [randint() << 64 | randint() for _ in range(3 * 10 ** 5 + 1)]
T = int(input())
for _ in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	left_top = -1
	right_top = N
	L = list(range(-1, N - 1))
	R = list(range(1, N + 1))
	Rev = [[] for _ in range(N + 1)]
	for (idx_A, a) in enumerate(A):
		Rev[a].append(idx_A)
	Vanish = [[] for _ in range(N + 1)]
	for (rev, a) in zip(reversed(Rev), range(N, 0, -1)):
		for idx_A in rev:
			(l, r) = (L[idx_A], R[idx_A])
			d = r - l - 1
			Vanish[d].append(a)
			if r != right_top:
				L[r] = l
			if l != left_top:
				R[l] = r
	remain_cnt = N
	remain_hash = 0
	correct_hash = 0
	for (i, a) in enumerate(A, 1):
		remain_hash ^= Hash[a]
		correct_hash ^= Hash[i]
	Ans = [0] * (N + 1)
	for (correct_cnt, Van) in zip(range(N, 0, -1), Vanish[1:]):
		if remain_cnt == correct_cnt and remain_hash == correct_hash:
			Ans[remain_cnt] = 1
		for a in Van:
			correct_hash ^= Hash[remain_cnt]
			remain_hash ^= Hash[a]
			remain_cnt -= 1
	print(''.join(map(str, Ans[N:0:-1])))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	d = dict()
	if a[-1] == 1:
		a = a[::-1]
	for (i, x) in enumerate(a):
		if x in d:
			d[x].append(i)
		else:
			d[x] = list()
			d[x].append(i)
	ans = []
	flag = True
	L = -1
	R = n
	for i in range(1, n):
		if i == 1:
			if 1 in d:
				ans.append('1')
			else:
				ans.append('0')
		elif ans[-1] == '1' and len(d[i - 1]) == 1:
			if a[L + 1] == i - 1:
				L += 1
			elif a[R - 1] == i - 1:
				R -= 1
			else:
				ans.append('0')
				continue
			if i in d:
				ans.append('1')
			else:
				ans.append('0')
		else:
			ans.append('0')
			continue
	flag = True
	for i in range(1, n + 1):
		if i in d and len(d[i]) == 1:
			continue
		else:
			flag = False
			break
	if flag:
		ans.append('1')
	else:
		ans.append('0')
	print(''.join(ans[::-1]))


import sys
input = sys.stdin.readline

def fun(l, r, val, che, ar):
	while l <= r:
		mid = l + (r - l) // 2
		if fun1(mid, ar) < val:
			l = mid + 1
		elif che[mid] == 1:
			return mid
		else:
			r = mid - 1

def update(inp, add, ar):
	global n
	while inp < n:
		ar[inp] += add
		inp += inp & -inp

def fun1(inp, ar):
	global n
	ans = 0
	while inp:
		ans += ar[inp]
		inp -= inp & -inp
	return ans
for _ in range(int(input())):
	nn = int(input())
	n = nn + 1
	br = list(map(int, input().split()))
	ar = [0] * n
	arb = [0] * n
	ch = [0] * n
	chb = [0] * n
	dic = {}
	ans = [-1] * n
	for i in range(nn):
		if br[i] in dic:
			dic[br[i]].append(i)
		else:
			dic[br[i]] = [i]
	for i in range(1, n):
		if i in dic:
			for j in dic[i]:
				temval = fun1(j + 1, ar)
				if temval == 0:
					fl = 0
				else:
					fl = fun(0, j + 1, fun1(j + 1, ar), ch, ar)
				j = nn - 1 - j
				temval = fun1(j + 1, arb)
				if temval == 0:
					rl = 0
				else:
					rl = fun(0, j + 1, fun1(j + 1, arb), chb, arb)
				ans[i] = max(ans[i], nn - (rl + fl))
			for j in dic[i]:
				ch[j + 1] = 1
				chb[nn - j] = 1
				update(j + 1, 1, ar)
				update(nn - j, 1, arb)
	mi = [0]
	va = ans[1]
	for i in range(1, n):
		va = min(va, ans[i])
		mi.append(va)
	final = [0] * n
	for i in range(1, n):
		req = n - i
		if mi[i] >= req:
			final[req] = 1
	for i in range(1, n):
		print(final[i], end='')
	print()


from collections import deque
import sys

def input():
	return sys.stdin.readline().rstrip()

def slv():
	n = int(input())
	a = list(map(int, input().split()))
	a = deque(a)
	count = [0] * (n + 1)
	ans = [0] * (n + 1)
	for v in a:
		count[v] += 1
	if all((count[i] > 0 for i in range(1, n + 1))):
		ans[1] = 1
	for k in range(n, 1, -1):
		number = n + 1 - k
		if number == 1:
			if count[number] >= 1:
				ans[k] = 1
			else:
				break
		elif a and (a[0] == number - 1 or a[-1] == number - 1) and (count[number - 1] == 1) and (count[number] > 0):
			ans[k] = 1
			if a[0] == number - 1:
				a.popleft()
			else:
				a.pop()
		else:
			break
	res = ''.join(map(str, ans[1:]))
	print(res)
	return

def main():
	t = int(input())
	for i in range(t):
		slv()
	return
main()


import sys
from sys import stdin

class SegTree:

	def __init__(self, N, first):
		self.NO = 2 ** (N - 1).bit_length()
		self.First = first
		self.data = [first] * (2 * self.NO)

	def calc(self, l, r):
		return min(l, r)

	def update(self, ind, x):
		ind += self.NO - 1
		self.data[ind] = x
		while ind >= 0:
			ind = (ind - 1) // 2
			self.data[ind] = self.calc(self.data[2 * ind + 1], self.data[2 * ind + 2])

	def query(self, l, r):
		L = l + self.NO
		R = r + self.NO
		s = self.First
		while L < R:
			if R & 1:
				R -= 1
				s = self.calc(s, self.data[R - 1])
			if L & 1:
				s = self.calc(s, self.data[L - 1])
				L += 1
			L >>= 1
			R >>= 1
		return s

	def get(self, ind):
		ind += self.NO - 1
		return self.data[ind]
tt = int(stdin.readline())
for loop in range(tt):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	ST = SegTree(n, float('inf'))
	for i in range(n):
		ST.update(i, a[i])
	li = 0
	ri = n - 1
	ans = [0] * n
	for i in range(n - 1):
		if ST.query(li, ri + 1) == i + 1:
			ans[n - 1 - i] = 1
		if a[li] == i + 1:
			li += 1
		elif a[ri] == i + 1:
			ri -= 1
		else:
			break
	tmp = [0] * n
	for i in range(n):
		tmp[a[i] - 1] += 1
	if max(tmp) == 1 and min(tmp) == 1:
		ans[0] += 1
	print(''.join(map(str, ans)))


from collections import Counter
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	o = Counter(a)
	perm = (0, n - 1)
	answers = []
	w = True
	for i in range(n - 1):
		if not w:
			answers.append(False)
			continue
		if i + 1 in o:
			answers.append(True)
		else:
			answers.append(False)
			w = False
			continue
		(s, e) = perm
		if a[s] == i + 1 and o[i + 1] == 1:
			perm = (s + 1, e)
			continue
		elif a[e] == i + 1 and o[i + 1] == 1:
			perm = (s, e - 1)
		else:
			w = False
	for i in range(n):
		if o[i + 1] != 1:
			answers.append(False)
			break
	else:
		answers.append(True)
	answers = [1 if v else 0 for v in answers]
	answers.reverse()
	print(*answers, sep='')


import sys, io, os
Z = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
o = []
for _ in range(int(Z())):
	n = int(Z())
	a = [*map(int, Z().split())]
	b = [1] + [0] * n
	c = [0] + [0] * n
	p = l = 0
	while l < n and a[l] > p:
		if b[a[l]] == 0:
			b[a[l]] = 1
		else:
			b[a[l]] = 0
			l += 1
			break
		p = a[l]
		l += 1
	p = r = 0
	while r < n and a[-r - 1] > p:
		if b[a[-r - 1]] == 0 or n - r == l:
			b[a[-r - 1]] = 1
		else:
			b[a[-r - 1]] = 0
			r += 1
			break
		p = a[-r - 1]
		r += 1
	for i in range(l - 1, n + 1 - r):
		c[a[i]] = 1
	g = 0
	while g < n - 1 and b[g] and (b[g + 1] or c[g + 1]) and (not c[g]):
		g += 1
	o.append(str(len(set(a)) // n) + '0' * (n - 1 - g) + '1' * g)
print('\n'.join(o))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	cnt = [0] * (n + 1)
	numless = 0
	for i in a:
		cnt[i] += 1
	print(int(set(a) == set([i for i in range(1, n + 1)])), end='')
	if min(a) == 1:
		l = 0
		r = n - 1
		ans = n
		for i in range(n, 0, -1):
			if a[l] < n - i + 1:
				break
			if a[r] < n - i + 1:
				break
			if cnt[n - i + 1] == 0 or numless > 0:
				break
			ans = i
			if a[l] != n - i + 1 and a[r] != n - i + 1:
				break
			if a[l] == n - i + 1 and a[r] == n - i + 1:
				break
			if a[l] == n - i + 1:
				l += 1
				cnt[n - i + 1] -= 1
			if a[r] == n - i + 1:
				r -= 1
				cnt[n - i + 1] -= 1
			numless += cnt[n - i + 1]
		if ans == 1:
			ans += 1
		print(''.join([str(0) for i in range(ans - 2)]), end='')
		print(''.join([str(1) for i in range(n - ans + 1)]))
	else:
		print(''.join([str(0) for i in range(n - 1)]))


from math import sqrt
import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
T = int(input())
for _ in range(T):
	n = int(input())
	(greater_or_eq, found) = ([0] * (n + 1), [False] * (n + 1))
	arr = list(map(int, input().split()))
	ans = ['0'] * (n + 1)
	for (i, v) in enumerate(arr):
		found[v] = True
		if i and arr[i - 1] >= v:
			greater_or_eq[v] += 1
		if i + 1 < n and arr[i + 1] >= v:
			greater_or_eq[v] += 1
	for i in range(1, n + 1):
		if not found[i] or not greater_or_eq[i]:
			break
		ans[i] = '1'
		if greater_or_eq[i] > 1:
			break
	if len(set(arr)) == n:
		ans[n] = '1'
	ans = ans[1:][::-1]
	print(''.join(ans))


from sys import stdin
import heapq
t = int(stdin.readline())
for case in range(t):
	n = int(stdin.readline())
	a = [int(x) - 1 for x in stdin.readline().split()]
	s = [0 for x in range(n)]
	for x in a:
		s[x] += 1
	high = 0
	left = 0
	right = -1
	for x in range(n - 1):
		if s[x] == 0:
			break
		if x == 0:
			high += 1
		elif a[left] == x - 1:
			high += 1
			left += 1
		elif a[right] == x - 1:
			high += 1
			right -= 1
		else:
			break
		if s[x] > 1:
			break
	if len(set(a)) == n:
		print('1' + '0' * (n - 1 - high) + '1' * high)
	else:
		print('0' + '0' * (n - 1 - high) + '1' * high)


from sys import stdin, stdout
from collections import deque
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	lst = list((int(x) for x in stdin.readline().split()))
	l_bounds = [None] * n
	r_bounds = [None] * n
	q = []
	score = []
	for i in range(n):
		while q and lst[i] < lst[q[-1]]:
			q.pop(-1)
			score.pop(-1)
		if not q:
			l_bounds[i] = 0
		else:
			l_bounds[i] = score[-1] + 1
		q.append(i)
		score.append(i)
	lst.reverse()
	q = []
	score = []
	for i in range(n):
		while q and lst[i] <= lst[q[-1]]:
			q.pop(-1)
			score.pop(-1)
		if not q:
			r_bounds[i] = 0
		else:
			r_bounds[i] = score[-1] + 1
		q.append(i)
		score.append(i)
	lst.reverse()
	r_bounds.reverse()
	for i in range(n):
		r_bounds[i] = n - r_bounds[i]
	dic = {}
	for i in range(n):
		number = lst[i]
		span = r_bounds[i] - l_bounds[i]
		if number not in dic:
			dic[number] = -1
		dic[number] = max(dic[number], span)
	mini = [float('inf')]
	for i in range(1, n + 1):
		if i not in dic:
			mini.append(-1)
		else:
			mini.append(min(mini[i - 1], dic[i]))
	for i in range(n, 0, -1):
		if mini[i] >= n - i + 1:
			stdout.write('1')
		else:
			stdout.write('0')
	stdout.write('\n')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	inx = {}
	temp = 0
	for i in range(n):
		if l[i] in inx:
			temp = 1
			inx[l[i]].append(i + 1)
		else:
			inx[l[i]] = [i + 1]
	ans = []
	ch = 0
	for i in range(1, n + 1):
		if i not in inx:
			ans.append('0' * (n + 1 - i))
			break
		if len(inx[i]) > 1:
			ans.append('1')
			ans.append('0' * (n - i))
			break
		curr = inx[i][0] - 1
		if curr > 0 and curr < n - 1:
			if l[curr - 1] > i and l[curr + 1] > i:
				ans.append('1')
				ans.append('0' * (n - i - 1))
				ch = 1
				break
			else:
				ans.append('1')
		else:
			ans.append('1')
	if ch == 1:
		if temp == 0:
			ans.append('1')
		else:
			ans.append('0')
	print(''.join(ans[::-1]))


from sys import stdout, stdin, maxsize
from collections import defaultdict, deque
import math
import bisect
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	l = list(map(int, stdin.readline().split()))
	ans = ['0'] * n
	if len(set(l)) == n:
		ans[0] = '1'
	if min(l) == 1:
		ans[n - 1] = '1'
	ind = [-1] * n
	fre = [0] * n
	for i in range(n):
		ind[l[i] - 1] = i
		fre[l[i] - 1] += 1
	(st, en) = (0, n - 1)
	for i in range(n):
		temp = ind[i]
		if temp <= en and temp >= st:
			ans[n - i - 1] = '1'
		if temp == st:
			st += 1
		elif temp == en:
			en -= 1
		else:
			break
		if fre[i] > 1:
			break
	an = ''.join(ans)
	stdout.write(an + '\n')


from sys import stdin
input = stdin.readline

def rating(arr):
	arr = list(map(lambda s: s - 1, lst))
	cnt = [0] * len(arr)
	ans = [0] * len(arr)
	for i in arr:
		cnt[i] += 1
	ans[0] = 0 if cnt.count(0) > 0 else 1
	ans[-1] = int(cnt[0] > 0)
	l = 0
	r = len(arr) - 1
	for i in range(1, len(arr)):
		j = i - 1
		if cnt[j] == 1 and cnt[i]:
			if arr[l] == j:
				l += 1
			elif arr[r] == j:
				r -= 1
			else:
				break
			ans[len(arr) - i - 1] = 1
		else:
			break
	return ''.join(list(map(str, ans)))
for i in range(int(input())):
	a = input()
	lst = list(map(int, input().strip().split()))
	print(rating(lst))


import sys
sys.setrecursionlimit(10 ** 5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.buffer.readline())

def MI():
	return map(int, sys.stdin.buffer.readline().split())

def LI():
	return list(map(int, sys.stdin.buffer.readline().split()))

def LI1():
	return list(map(int1, sys.stdin.buffer.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def BI():
	return sys.stdin.buffer.readline().rstrip()

def SI():
	return sys.stdin.buffer.readline().rstrip().decode()
inf = 10 ** 16
md = 10 ** 9 + 7

class SparseTableMin:

	def __init__(self, aa):
		w = len(aa)
		h = w.bit_length()
		table = [aa] + [[-1] * w for _ in range(h - 1)]
		tablei1 = table[0]
		for i in range(1, h):
			tablei = table[i]
			for j in range(w - (1 << i) + 1):
				rj = j + (1 << i - 1)
				tablei[j] = min(tablei1[j], tablei1[rj])
			tablei1 = tablei
		self.table = table

	def min(self, l, r):
		i = (r - l).bit_length() - 1
		tablei = self.table[i]
		Lmin = tablei[l]
		Rmin = tablei[r - (1 << i)]
		if Lmin < Rmin:
			Rmin = Lmin
		return Rmin
for _ in range(II()):
	n = II()
	aa = LI1()
	ans = [0] * n
	ex = [False] * n
	for a in aa:
		if a < n:
			ex[a] = True
	if ex[0]:
		ans[n - 1] = 1
	if sum(ex) == n:
		ans[0] = 1
	sp = SparseTableMin(aa)
	(l, r) = (0, n - 1)
	for i in range(n - 2):
		if aa[l] == i and sp.min(l + 1, r + 1) == i + 1:
			ans[n - 2 - i] = 1
			l += 1
		elif aa[r] == i and sp.min(l, r) == i + 1:
			ans[n - 2 - i] = 1
			r -= 1
		else:
			break
	print(*ans, sep='')