You are given a permutation $p=[p_1, p_2, \ldots, p_n]$ of integers from $1$ to $n$. Let's call the number $m$ ($1 \le m \le n$) beautiful, if there exists two indices $l, r$ ($1 \le l \le r \le n$), such that the numbers $[p_l, p_{l+1}, \ldots, p_r]$ is a permutation of numbers $1, 2, \ldots, m$.

For example, let $p = [4, 5, 1, 3, 2, 6]$. In this case, the numbers $1, 3, 5, 6$ are beautiful and $2, 4$ are not. It is because:  if $l = 3$ and $r = 3$ we will have a permutation $[1]$ for $m = 1$;  if $l = 3$ and $r = 5$ we will have a permutation $[1, 3, 2]$ for $m = 3$;  if $l = 1$ and $r = 5$ we will have a permutation $[4, 5, 1, 3, 2]$ for $m = 5$;  if $l = 1$ and $r = 6$ we will have a permutation $[4, 5, 1, 3, 2, 6]$ for $m = 6$;  it is impossible to take some $l$ and $r$, such that $[p_l, p_{l+1}, \ldots, p_r]$ is a permutation of numbers $1, 2, \ldots, m$ for $m = 2$ and for $m = 4$. 

You are given a permutation $p=[p_1, p_2, \ldots, p_n]$. For all $m$ ($1 \le m \le n$) determine if it is a beautiful number or not.


-----Input-----

The first line contains the only integer $t$ ($1 \le t \le 1000$)  — the number of test cases in the input. The next lines contain the description of test cases.

The first line of a test case contains a number $n$ ($1 \le n \le 2 \cdot 10^5$) — the length of the given permutation $p$. The next line contains $n$ integers $p_1, p_2, \ldots, p_n$ ($1 \le p_i \le n$, all $p_i$ are different) — the given permutation $p$.

It is guaranteed, that the sum of $n$ from all test cases in the input doesn't exceed $2 \cdot 10^5$.


-----Output-----

Print $t$ lines — the answers to test cases in the order they are given in the input. 

The answer to a test case is the string of length $n$, there the $i$-th character is equal to $1$ if $i$ is a beautiful number and is equal to $0$ if $i$ is not a beautiful number.


-----Example-----
Input
3
6
4 5 1 3 2 6
5
5 3 1 2 4
4
1 4 3 2

Output
101011
11111
1001



-----Note-----

The first test case is described in the problem statement.

In the second test case all numbers from $1$ to $5$ are beautiful:  if $l = 3$ and $r = 3$ we will have a permutation $[1]$ for $m = 1$;  if $l = 3$ and $r = 4$ we will have a permutation $[1, 2]$ for $m = 2$;  if $l = 2$ and $r = 4$ we will have a permutation $[3, 1, 2]$ for $m = 3$;  if $l = 2$ and $r = 5$ we will have a permutation $[3, 1, 2, 4]$ for $m = 4$;  if $l = 1$ and $r = 5$ we will have a permutation $[5, 3, 1, 2, 4]$ for $m = 5$.

Difficulty: EASY
Tags: Mathematics

Amortized analysis

Data structures

Implementation
Skill types: Data structures

Amortized analysis

Starter code:

Solutions:
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	index_list = [1] * n
	for i in range(n):
		index_list[l[i] - 1] = i
	lp = [1]
	(mi, ma) = (index_list[0], index_list[0])
	for j in range(1, n):
		if j == n - 1:
			lp.append(1)
		else:
			mi = min(mi, index_list[j])
			ma = max(ma, index_list[j])
			if ma - mi == j:
				lp.append(1)
			else:
				lp.append(0)
	print(*lp, sep='')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = {}
	for i in range(n):
		d[a[i]] = i
	ans = ''
	mn = 200001
	mx = -1
	for i in range(1, n + 1):
		if mn > d[i]:
			mn = d[i]
		if mx < d[i]:
			mx = d[i]
		if mx - mn + 1 > i:
			ans += '0'
		else:
			ans += '1'
	print(ans)


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')
testcases = int(input())
for j in range(testcases):
	n = int(input())
	vals = list(map(int, input().split()))
	indices = [0] * n
	for s in range(n):
		indices[vals[s] - 1] = s
	maxy = indices[0]
	minny = indices[0]
	outy = []
	for s in range(n):
		maxy = max(maxy, indices[s])
		minny = min(minny, indices[s])
		if maxy - minny + 1 == s + 1:
			outy.append(str(1))
		else:
			outy.append(str(0))
	print(''.join(outy))


q = int(input())
for p in range(q):
	n = int(input())
	line = list(map(int, input().split()))
	one = line.index(1)
	lens = [() for i in range(n + 1)]
	for i in range(n):
		if i < one:
			lens[line[i]] = (one - i, 0)
		else:
			lens[line[i]] = (0, i - one)
	max_len_l = 0
	max_len_r = 0
	for i in range(1, n + 1):
		max_len_l = max(max_len_l, lens[i][0])
		max_len_r = max(max_len_r, lens[i][1])
		if max_len_l + max_len_r < i:
			print(1, end='')
		else:
			print(0, end='')
	print()


from sys import stdin

def input():
	return stdin.readline()[:-1]
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	idx = [0] * (n + 1)
	for i in range(n):
		idx[l[i]] = i
	maxs = [idx[1]] * (n + 1)
	mins = [idx[1]] * (n + 1)
	for i in range(2, n + 1):
		maxs[i] = max(maxs[i - 1], idx[i])
		mins[i] = min(mins[i - 1], idx[i])
	out = []
	for i in range(1, n + 1):
		if maxs[i] - mins[i] == i - 1:
			out.append(1)
		else:
			out.append(0)
	print(''.join(list(map(str, out))))


for _ in range(int(input())):
	ln = int(input())
	a = [int(x) for x in input().split()]
	p = {}
	for i in range(ln):
		p[a[i] - 1] = i
	l = 10 ** 6
	r = -1
	rs = []
	for i in range(ln):
		l = min(l, p[i])
		r = max(r, p[i])
		rs.append(1 if r - l == a[p[i]] - 1 else 0)
	print(''.join([str(x) for x in rs]))


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	ind = [0] * (n + 1)
	k = 1
	for a in arr:
		ind[a] = k
		k += 1
	s = '1'
	res = [ind[1]]
	l = ind[1]
	r = ind[1]
	for i in range(2, n + 1):
		l = min(l, ind[i])
		r = max(r, ind[i])
		if r - l + 1 == i:
			s += '1'
		else:
			s += '0'
	print(s)


for nt in range(int(input())):
	n = int(input())
	s = '1'
	l = list(map(int, input().split()))
	d = {}
	for i in range(n):
		d[str(l[i])] = i
	left = d['1']
	right = left
	num = 2
	while num != n + 1:
		i = d[str(num)]
		if i < left:
			left = i
		elif i > right:
			right = i
		if right - left == num - 1:
			s += '1'
		else:
			s += '0'
		num += 1
	print(s)


(z, zz) = (input, lambda : list(map(int, z().split())))
fast = lambda : stdin.readline().strip()
zzz = lambda : [int(i) for i in fast().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = 1
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
num = int(z())
for _ in range(num):
	n = int(z())
	lst = zzz()
	idx = [0] * (n + 1)
	for i in range(n):
		idx[lst[i]] = i
	left = n + 1
	right = -1
	ans = ['0'] * n
	for i in range(1, n + 1):
		x = idx[i]
		if x < left:
			left = x
		if x > right:
			right = x
		if right - left + 1 == i:
			ans[i - 1] = '1'
	print(''.join(ans))


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(input().split())
	po = [0] * n
	for i in range(n):
		po[int(l[i]) - 1] = i
	mip = po[0]
	map = po[0]
	print(1, end='')
	for i in range(1, n):
		mip = min(mip, po[i])
		map = max(map, po[i])
		if map - mip == i:
			print(1, end='')
		else:
			print(0, end='')
	print()


for i in range(int(input())):
	n = int(input())
	arr = {int(i): x for (x, i) in enumerate(input().split())}
	ans = [0] * len(arr)
	mn = 10 ** 10
	mx = -1
	for i in range(1, len(arr) + 1):
		mn = min(mn, arr[i])
		mx = max(mx, arr[i])
		if mx - mn == i - 1:
			ans[i - 1] = 1
	print(''.join([str(i) for i in ans]))


import array as arr
T = int(input())
for t in range(T):
	n = int(input())
	p = arr.array('i', [int(x) - 1 for x in input().split()])
	for i in range(n):
		if p[i] == 0:
			a = i
			break
	b = a
	ans = []
	ans.append('1')
	M = 0
	m = 0
	for i in range(1, n):
		if a > 0 and (b >= n - 1 or p[a - 1] < p[b + 1]):
			a = a - 1
			if p[a] > M:
				M = p[a]
		else:
			b = b + 1
			if p[b] > M:
				M = p[b]
		if M == b - a:
			ans.append((M - m - 1) * '0' + '1')
			m = M
	print(''.join(ans))


from __future__ import division, print_function
from io import BytesIO, IOBase
import os, sys, math, heapq, copy
from collections import defaultdict, deque
from bisect import bisect_left, bisect_right
from functools import cmp_to_key
from itertools import permutations, combinations, combinations_with_replacement
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
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))
input = lambda : sys.stdin.readline().rstrip('\r\n')
mod = 1000000007

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

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

def get_float():
	return float(sys.stdin.readline().strip())

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

def get_strs():
	return map(str, sys.stdin.readline().strip().split())

def get_floats():
	return map(float, sys.stdin.readline().strip().split())

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

def list_strs():
	return list(map(str, sys.stdin.readline().strip().split()))

def list_floats():
	return list(map(float, sys.stdin.readline().strip().split()))

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		l = list_ints()
		l = [[l[i], i] for i in range(n)]
		l.sort()
		minimum = math.inf
		maximum = -math.inf
		for i in range(n):
			minimum = min(minimum, l[i][1])
			maximum = max(maximum, l[i][1])
			if maximum - minimum == i:
				print(1, end='')
			else:
				print(0, end='')
		print()
main()


def check(n, lst):
	pos_p = [0 for j in range(n)]
	for i in range(n):
		pos_p[lst[i] - 1] = i
	(pmin, pmax, s) = (pos_p[0], pos_p[0], '')
	for i in range(n):
		if pos_p[i] < pmin:
			pmin = pos_p[i]
		if pos_p[i] > pmax:
			pmax = pos_p[i]
		if pmax - pmin != i:
			s += '0'
		else:
			s += '1'
	return s
for _ in range(int(input())):
	m = int(input())
	p = [int(i) for i in input().split()]
	print(check(m, p))


def solve(lst):
	if len(lst) == 1:
		return 1
	h = {}
	ones = {}
	p = sorted(lst)[::-1]
	for i in range(len(lst)):
		h[lst[i]] = i
	ans = ''
	mind = len(lst)
	maxd = 0
	while p:
		k = p.pop()
		mind = min(h[k], mind)
		maxd = max(h[k], maxd)
		if maxd - mind == k - 1:
			ans += '1'
		else:
			ans += '0'
	return ans
k = int(input())
for i in range(k):
	p = int(input())
	s = list(map(int, input().split()))
	print(solve(s))


def solve():
	n = int(input())
	(a, p, ans) = (list(map(int, input().split(' '))), [0] * n, [0] * n)
	for (i, v) in enumerate(a):
		p[v - 1] = i
	(l, r) = (n, -1)
	for (i, v) in enumerate(p):
		l = min(v, l)
		r = max(v, r)
		ans[i] = r - l <= i
	print(*map(int, ans), sep='')
n = int(input())
for i in range(n):
	solve()


T = int(input())
for t in range(0, T):
	n = int(input())
	P = list(map(int, input().split()))
	loi = [0] * n
	for i in range(0, n):
		loi[P[i] - 1] = i
	M = {}
	l = loi[0]
	r = loi[0]
	for i in range(0, n):
		if loi[i] < l:
			l = loi[i]
		if loi[i] > r:
			r = loi[i]
		if r - l == i:
			M[i + 1] = '1'
		else:
			M[i + 1] = '0'
	for i in range(1, n + 1):
		print(M[i], end='')
	print()


l = int(input())
for k in range(l):
	n = int(input())
	st = str(input())
	sp = [0 for i in range(n)]
	pos = [0 for i in range(n)]
	k = 0
	for i in st.split():
		sp[k] = int(i)
		pos[int(i) - 1] = k
		k += 1
	M = 0
	m = n
	for i in range(n):
		M = max(M, pos[i])
		m = min(m, pos[i])
		if M - m > i:
			print(0, end='')
		else:
			print(1, end='')
	print()


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	index = {}
	print(1, end='')
	for i in range(len(l)):
		index[l[i]] = i + 1
	u = index[1]
	v = index[1]
	for i in range(1, n + 1):
		u = min(index[i], u)
		v = max(index[i], v)
		if i == 1:
			continue
		if v - u == i - 1:
			print(1, end='')
		else:
			print(0, end='')
	print()


for _ in range(int(input())):
	n = int(input())
	p = list(map(int, input().split()))
	p = sorted([(p[i], i) for i in range(n)])
	s = '1'
	(l, r, m) = (p[0][1], p[0][1], 1)
	for i in range(1, n):
		m += 1
		(l, r) = (min(p[i][1], l), max(p[i][1], r))
		if r - l + 1 == m:
			s += '1'
		else:
			s += '0'
	print(s)


def perms(val):
	lst = [int(i) for i in val.split()]
	maxi = 0
	mini = len(lst)
	visited = [0] * len(lst)
	position = [0] * len(lst)
	ordered = sorted(lst)
	beas = [0] * len(lst)
	indexer = 0
	for i in lst:
		position[i - 1] = indexer
		indexer += 1
	for i in ordered:
		ind = position[i - 1]
		visited[ind] = 1
		if ind < mini:
			mini = ind
		if ind > maxi:
			maxi = ind
		if maxi - mini + 1 == i:
			beas[i - 1] = 1
	strs = ''
	for i in beas:
		strs += str(i)
	print(strs)

def main():
	total = eval(input())
	for i in range(total):
		n = input()
		val = input()
		perms(val)
main()


def f():
	n = int(input())
	A = [int(s) for s in input().split()]
	ans = [0] * n
	ans[0] = 1
	ans[n - 1] = 1
	i = 0
	j = n - 1
	outMin = n + 1
	while j > i:
		if A[i] > A[j]:
			if A[i] < outMin:
				outMin = A[i]
			i += 1
		else:
			if A[j] < outMin:
				outMin = A[j]
			j -= 1
		if j - i == outMin - 2:
			ans[j - i] = 1
	print(''.join((str(i) for i in ans)))
t = int(input())
for i in range(t):
	f()


def solve():
	n = int(input())
	p = input().split()
	inv = [0 for i in range(n + 1)]
	for i in range(n):
		(p[i], inv[int(p[i])]) = (int(p[i]), i)
	output = ''
	(mx, mn) = (0, n)
	for i in range(1, n + 1):
		(mx, mn) = (max(inv[i], mx), min(inv[i], mn))
		output += '1' if mx - mn + 1 == i else '0'
	return output
t = int(input())
for Test in range(t):
	print(solve())


import sys
from collections import defaultdict, deque
from math import sqrt

def input():
	return sys.stdin.readline()[:-1]

def solve():
	n = int(input())
	a = [int(x) - 1 for x in input().split()]
	p = [0] * n
	for i in range(n):
		p[a[i]] = i
	l = n
	r = 0
	ans = ''
	for i in range(n):
		l = min(l, p[i])
		r = max(r, p[i])
		if r - l == i:
			ans += '1'
		else:
			ans += '0'
	print(ans)
t = int(input())
for _ in range(t):
	solve()


from collections import defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	ls = list(map(int, input().strip().split()))
	dic = defaultdict(list)
	for (i, val) in enumerate(ls):
		dic[val] = i
	maxi = mini = 0
	ans = ''
	for (key, val) in sorted(dic.items()):
		if key == 1:
			maxi = mini = val
			ans += '1'
		elif val > mini and val < maxi or val == mini - 1 or val == maxi + 1:
			if maxi < val:
				maxi = val
			else:
				mini = min(mini, val)
			if maxi - mini == key - 1:
				ans += '1'
			else:
				ans += '0'
		else:
			if maxi < val:
				maxi = val
			else:
				mini = min(mini, val)
			ans += '0'
	print(ans)


t = int(input())
for x in range(t):
	n = int(input())
	s = list(input().split(' '))
	flg = True
	lst = [None] * (n + n)
	for i in range(n):
		ind = int(s[i])
		lst[ind] = i
	ss = []
	lf = rt = lst[1]
	for i in range(1, n + 1):
		while lf - 1 >= 0:
			if i >= int(s[lf - 1]):
				lf -= 1
			else:
				break
		while rt + 1 < n:
			if i >= int(s[rt + 1]):
				rt += 1
			else:
				break
		if rt - lf + 1 == i:
			ss.append('1')
		else:
			ss.append('0')
	print(''.join(ss))


import math
T = int(input())
anwer = ''
for t in range(T):
	n = int(input())
	gotten = list(map(int, input().split(' ')))
	p = [0] * n
	i = 0
	for g in gotten:
		p[g - 1] = i
		i += 1
	minI = n
	maxI = 0
	ans = ''
	for i in range(n):
		minI = min(minI, p[i])
		maxI = max(maxI, p[i])
		if maxI - minI == i:
			ans += '1'
		else:
			ans += '0'
	anwer += ans + '\n'
print(anwer)


for t in range(int(input())):
	n = int(input())
	perm = [n + 1]
	perm.extend(list(map(int, input().split())))
	perm.append(n + 2)
	answers = [1]
	top_value = 1
	left_bound = perm.index(1)
	right_bound = left_bound
	for i in range(2, n + 1):
		if perm[left_bound - 1] < perm[right_bound + 1]:
			left_bound -= 1
			top_value = max(top_value, perm[left_bound])
		else:
			right_bound += 1
			top_value = max(top_value, perm[right_bound])
		if top_value == i:
			answers.append(1)
		else:
			answers.append(0)
	print(''.join(map(str, answers)))


t = int(input())
for i in range(t):
	n = int(input())
	nums = list(map(int, input().split()))
	visited = [0] * (len(nums) + 1)
	indexs = [-1] * (len(nums) + 1)
	for i in range(1, len(nums) + 1):
		indexs[nums[i - 1]] = i
	left = indexs[1]
	right = indexs[1]
	res = ''
	for i in range(1, len(nums) + 1):
		visited[i] = 1
		while left >= 1:
			if visited[nums[left - 1]] == 1:
				left -= 1
			else:
				break
		left += 1
		while right <= len(nums):
			if visited[nums[right - 1]] == 1:
				right += 1
			else:
				break
		right -= 1
		if right - left + 1 == i:
			res += '1'
		else:
			res += '0'
	print(res)


x = int(input())
for i in range(x):
	y = int(input())
	k = [0] * y
	q = '1'
	z = input().split(' ')
	for j in range(y):
		k[int(z[j]) - 1] = j
	minn = k[0]
	maxx = k[0]
	for j in range(1, y):
		minn = min(minn, k[j])
		maxx = max(maxx, k[j])
		if maxx - minn != j:
			q += '0'
		else:
			q += '1'
	print(q)


for _ in range(int(input())):
	input()
	nums = [int(x) for x in input().split()]
	new_ar = list(zip(nums, [i for i in range(len(nums))]))
	new_ar.sort()
	maxx = new_ar[0][1]
	minn = new_ar[0][1]
	s = '1'
	for j in range(1, len(new_ar)):
		if new_ar[j][1] > maxx:
			maxx = new_ar[j][1]
		if new_ar[j][1] < minn:
			minn = new_ar[j][1]
		if maxx - minn < j + 1:
			s += '1'
		else:
			s += '0'
	print(s)


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	for i in range(n):
		b.append([a[i], i + 1])
	b.sort()
	(ma, mi) = (b[0][1], b[0][1])
	print(1, end='')
	for i in range(1, n):
		if b[i][1] > ma:
			ma = b[i][1]
		if b[i][1] < mi:
			mi = b[i][1]
		if ma - mi == i:
			print(1, end='')
		else:
			print(0, end='')
	print()


for _ in range(int(input())):
	n = int(input())
	perm = list(map(int, input().split()))
	index = [None] * n
	for i in range(n):
		index[perm[i] - 1] = i
	result = ['0'] * n
	cmax = -1
	cmin = 1000000.0
	for i in range(n):
		cmin = min(cmin, index[i])
		cmax = max(cmax, index[i])
		if cmax - cmin == i:
			result[i] = '1'
	print(''.join(result))


t = int(input())
for i in range(t):
	n = int(input())
	lista = list(map(int, input().split()))
	pos = {}
	for j in range(n):
		pos[lista[j]] = j
	l = r = pos[1]
	ans = '1'
	for j in range(2, n + 1):
		l = min(l, pos[j])
		r = max(r, pos[j])
		if r - l + 1 == j:
			ans += '1'
		else:
			ans += '0'
	print(ans)


from sys import stdin
from collections import defaultdict
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	p = list(map(int, stdin.readline().rstrip().split(' ')))
	posDict = {}
	for i in range(n):
		posDict[p[i]] = i
	rangeArr = [1000000, -1]
	length = 0
	answerArr = []
	for i in range(1, n + 1):
		cur = posDict[i]
		if cur < rangeArr[0]:
			rangeArr[0] = cur
		if cur > rangeArr[1]:
			rangeArr[1] = cur
		if rangeArr[1] - rangeArr[0] == length:
			answerArr.append('1')
		else:
			answerArr.append('0')
		length += 1
	print(''.join(answerArr))


t = int(input())
for q in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	l = [-1] * n
	for i in range(n):
		l[a[i] - 1] = i
	s = '1'
	(mi, ma) = (l[0], l[0])
	for j in range(1, n):
		if j == n - 1:
			s += '1'
		else:
			mi = min(mi, l[j])
			ma = max(ma, l[j])
			if ma - mi == j:
				s += '1'
			else:
				s += '0'
	print(s)


from collections import defaultdict, deque
from itertools import permutations
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
from copy import deepcopy
int_input = lambda : int(stdin.readline())
string_input = lambda : stdin.readline()
multi_int_input = lambda : map(int, stdin.readline().split())
multi_input = lambda : stdin.readline().split()
list_input = lambda : list(map(int, stdin.readline().split()))
string_list_input = lambda : list(string_input())
MOD = pow(10, 9) + 7
test = int_input()
for _ in range(test):
	length = int_input()
	points = [0] * (length + 1)
	array = list_input()
	for (i, n) in enumerate(array):
		points[n] = i
	lmax = 9999999999999999999999
	rmax = -1
	result = []
	for i in range(1, length + 1):
		lmax = min(lmax, points[i])
		rmax = max(rmax, points[i])
		if rmax - lmax + 1 == i:
			result.append(1)
		else:
			result.append(0)
	for elements in result:
		print(elements, end='')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(p) for p in input().split()]
	table = [0] * (n + 1)
	for i in range(len(arr)):
		table[arr[i]] = i
	minIndex = maxIndex = table[1]
	res = ['1']
	for i in range(2, n + 1):
		minIndex = min(minIndex, table[i])
		maxIndex = max(maxIndex, table[i])
		if maxIndex - minIndex + 1 == i:
			res.append('1')
		else:
			res.append('0')
	print(''.join(res))


for kkk in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	for i in range(n):
		d[l[i]] = i
	ans = ['0' for i in range(n + 1)]
	ans[1] = '1'
	posleft = d[1]
	posright = d[1]
	for j in range(2, n + 1):
		if d[j] == posleft - 1 or d[j] == posright + 1:
			if ans[j - 1] == '1':
				ans[j] = '1'
		elif d[j] < posright and d[j] > posleft:
			if posright - posleft + 1 == j:
				ans[j] = '1'
		if d[j] < posleft:
			posleft = d[j]
		if d[j] > posright:
			posright = d[j]
	print(''.join(ans[1:]))


def bt(words, numList):
	word = words
	n = numList
	lst1 = []
	for k in range(len(word)):
		w = word[k]
		wlst = [0] * len(w)
		isBeautiful = ''
		for i in range(len(w)):
			wlst[int(w[i]) - 1] = i + 1
		minIndex = len(w)
		maxIndex = 0
		for i in range(len(wlst)):
			if wlst[i] < minIndex:
				minIndex = wlst[i]
			if wlst[i] > maxIndex:
				maxIndex = wlst[i]
			if maxIndex - minIndex + 1 == i + 1:
				isBeautiful = isBeautiful + '1'
			else:
				isBeautiful = isBeautiful + '0'
		lst1.append(isBeautiful)
	return lst1
numWords = eval(input())
words = []
numlst = []
for i in range(numWords):
	num = eval(input())
	word = input()
	words.append(word.split(' '))
	numlst.append(num)
lst = bt(words, numlst)
an = []
for j in lst:
	st = ''
	for k in j:
		st = st + str(k)
	an.append(st)
for j in an:
	print(j)


from typing import List, Tuple

def soln() -> None:

	def logic() -> None:
		n = int(input())
		arr: List[int] = [int(x) for x in input().split()]
		ans: List[Tuple[int, int]] = sorted([(arr[i], i) for i in range(len(arr))])
		ext = [ans[0][1]] * 2
		fin: List[str] = ['0'] * n
		for i in range(n):
			if ans[i][1] < ext[0]:
				ext[0] = ans[i][1]
			if ans[i][1] > ext[1]:
				ext[1] = ans[i][1]
			if ext[1] - ext[0] == i:
				fin[i] = '1'
		print(''.join(fin))
	for _ in range(int(input())):
		logic()
soln()


from math import sqrt, ceil

def ii():
	return int(input())

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

def li():
	return list(mi())

def si():
	return input()
abc = ['a', 'b', 'c']
t = ii()
while t:
	t -= 1
	n = ii()
	a = li()
	m = {}
	for i in range(n):
		m[a[i]] = i
	x = m[1]
	r = 0
	l = 0
	for i in range(n):
		x1 = x - m[i + 1]
		if x1 > 0:
			x1 = max(l, abs(x1)) + r + 1
		else:
			x1 = max(r, abs(x1)) + l + 1
		if x1 <= i + 1:
			print('1', end='')
		else:
			print('0', end='')
		prev1 = x - m[i + 1]
		if prev1 < 0:
			r = max(r, abs(prev1))
		else:
			l = max(l, abs(prev1))
	print()


n = int(input())

def solve():
	k = int(input())
	arr = [int(i) for i in input().split()]
	res = ['1']
	m = {c: i for (i, c) in enumerate(arr)}
	(mi, ma) = (m[1], m[1])
	for i in range(2, k + 1):
		pos = m[i]
		mi = min(mi, pos)
		ma = max(ma, pos)
		if ma - mi == i - 1:
			res.append('1')
		else:
			res.append('0')
	return ''.join(res)
for _ in range(n):
	print(solve())


import sys, math, itertools, heapq, collections, bisect, string, copy
input = lambda : sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10 ** 8)
inf = float('inf')
mod = 10 ** 9 + 7
ans = 0
count = 0
pro = 1
n = int(input())

def solve():
	n = int(input())
	ans = [0] * n
	ans[0] = 1
	P = list(map(int, input().split()))
	D = [0] * (n + 1)
	for i in range(n):
		D[P[i]] = i
	l = D[1]
	r = l + 1
	for i in range(2, n + 1):
		l = min(l, D[i])
		r = max(r, D[i] + 1)
		if r - l == i:
			ans[i - 1] = 1
	print(*ans, sep='')
for i in range(n):
	solve()


from math import *
from collections import *
import sys
sys.setrecursionlimit(10 ** 9)
t = int(input())
for y in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ans = ['1']
	le = 1
	l = a.index(1)
	l -= 1
	r = l + 2
	m = 1
	while le < n:
		if l != -1 and r != n:
			if a[l] > a[r]:
				m = max(m, a[r])
				r += 1
				if m == le + 1:
					ans.append('1')
				else:
					ans.append('0')
			else:
				m = max(m, a[l])
				l -= 1
				if m == le + 1:
					ans.append('1')
				else:
					ans.append('0')
		elif l != -1:
			m = max(m, a[l])
			l -= 1
			if m == le + 1:
				ans.append('1')
			else:
				ans.append('0')
		else:
			m = max(m, a[r])
			r += 1
			if m == le + 1:
				ans.append('1')
			else:
				ans.append('0')
		le += 1
	print(''.join(ans))


import sys
import collections
from collections import Counter
import itertools
import math
import timeit

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

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

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

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

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
t = ii()
MAXN = 2 * 10 ** 5
for _ in range(t):
	n = ii()
	d = li()
	d = [MAXN + 1] + d
	d.append(MAXN + 1)
	res = [0] * n
	i = d.index(1)
	j = i + 1
	cs = 0
	for c in range(1, n + 1):
		if d[i] < d[j]:
			cs += d[i]
			if c * (c + 1) == 2 * cs:
				res[c - 1] = 1
			i -= 1
		else:
			cs += d[j]
			if c * (c + 1) == 2 * cs:
				res[c - 1] = 1
			j += 1
	prr(res, '')


t = int(input())
for x in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	index = [None for i in range(n)]
	for i in range(n):
		index[a[i] - 1] = i
	ans = ['0' for i in range(n)]
	min_index = n + 1
	max_index = -1
	for m in range(n):
		if index[m] > max_index:
			max_index = index[m]
		if index[m] < min_index:
			min_index = index[m]
		if max_index - min_index == m:
			ans[m] = '1'
	print(''.join(ans))


t = int(input())
for tc in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	pair = [(y, x) for (x, y) in enumerate(p)]
	pair.sort()
	idx = [x for (y, x) in pair]
	sm = idx[0]
	lg = idx[0]
	ans = []
	for i in range(n):
		sm = min(sm, idx[i])
		lg = max(lg, idx[i])
		if lg - sm == i:
			ans.append('1')
		else:
			ans.append('0')
	print(''.join(ans))


def solve():
	n = int(input())
	wynik = []
	t = [int(a) for a in input().split(' ')]
	s = {}
	for i in range(n):
		s[t[i]] = i
	wynik.append('1')
	l = r = s[1]
	for i in range(2, n + 1):
		if s[i] < l:
			l = s[i]
		if s[i] > r:
			r = s[i]
		d = r - l + 1
		wynik.append('1' if d == i else '0')
	return ''.join(wynik)
t = int(input())
for i in range(t):
	print(solve())


t = int(input())
for _ in range(t):
	N = int(input())
	p = list(map(int, input().split()))
	idx = {}
	for i in range(N):
		idx[p[i]] = i
	left = N + 1
	right = -1
	ans = [0] * N
	for i in range(1, N + 1):
		x = idx[i]
		if x < left:
			left = x
		if x > right:
			right = x
		if right - left + 1 == i:
			ans[i - 1] = 1
	print(''.join(map(str, ans)))


t = int(input())
for aoao in range(t):
	n = int(input())
	per = [0] * n
	j = 1
	for i in (int(s) for s in input().split()):
		per[i - 1] = j
		j += 1
	s = ''
	start = end = per[0]
	for i in range(n):
		start = min(start, per[i])
		end = max(end, per[i])
		if end - start == i:
			s += '1'
		else:
			s += '0'
	print(s)


t = int(input())
for i in range(t):
	n = int(input())
	s = input().split()
	l = [0] * len(s)
	l1 = [0] * len(s)
	l1[0] = '1'
	k = 0
	for i in range(0, len(s)):
		l[int(s[i]) - 1] = i
	diff = 0
	min1 = max1 = l[0]
	for i in range(1, len(l)):
		max1 = max(max1, l[i])
		min1 = min(min1, l[i])
		if max1 - min1 == i:
			l1[i] = '1'
		else:
			l1[i] = '0'
	print(''.join(l1))


lpn = int(input())
for loop in range(lpn):
	n = int(input())
	p = list(map(int, input().split()))
	for i in range(n):
		if p[i] == 1:
			oneind = i
			break
	l = oneind
	r = oneind
	nmax = 1
	ans = [0] * n
	ans[0] = 1
	for i in range(n - 1):
		if l == 0 or (r != n - 1 and p[l - 1] > p[r + 1]):
			r += 1
			nmax = max(nmax, p[r])
			if i + 2 == nmax:
				ans[i + 1] = 1
		else:
			l -= 1
			nmax = max(nmax, p[l])
			if i + 2 == nmax:
				ans[i + 1] = 1
	print(''.join(map(str, ans)))


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	n = int(input())
	startpos = -1
	data = []
	data.append(300000)
	data += [i for i in input().split()]
	data.append(300000)
	for i in range(len(data)):
		data[i] = int(data[i])
		if data[i] == 1:
			startpos = i
	max_idx = leftptr = rightptr = startpos
	out = [0 for i in range(n)]
	while leftptr > 0 and rightptr <= n:
		if data[leftptr - 1] < data[rightptr + 1]:
			leftptr -= 1
			if data[leftptr] > data[max_idx]:
				max_idx = leftptr
		else:
			rightptr += 1
			if data[rightptr] > data[max_idx]:
				max_idx = rightptr
		if data[max_idx] + leftptr == rightptr + 1:
			out[data[max_idx] - 1] = 1
	out[0] = 1
	for i in out:
		print(i, end='')
	print()


t = int(input())
res = []
for k in range(t):
	n = int(input())
	indice = {}
	p = [int(i) for i in input().split()]
	for i in range(len(p)):
		indice[p[i]] = i
	bitres = ''
	mini = 999999999999
	maxi = -1
	for i in range(1, n + 1):
		if indice[i] < mini:
			mini = indice[i]
		if indice[i] > maxi:
			maxi = indice[i]
		if maxi - mini <= i - 1:
			bitres += '1'
		else:
			bitres += '0'
	res.append(bitres)
for ligne in res:
	print(ligne)


def solve(n, p):
	s = '1'
	d = {v: i for (i, v) in enumerate(p)}
	x = set()
	(maxx, minx) = (d[1], d[1])
	for v in range(2, n + 1):
		maxx = max(maxx, d[v])
		minx = min(minx, d[v])
		if maxx - minx + 1 == v:
			s += '1'
		else:
			s += '0'
	return s

def main():
	for _ in range(int(input())):
		n = int(input())
		p = list(map(int, input().split()))
		print(solve(n, p))
main()


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	pos = [0] * (n + 1)
	for (i, val) in enumerate(arr):
		pos[val] = i
	ans = ['0'] * n
	curr_max = curr_min = pos[1]
	ans[0] = '1'
	for val in range(2, n + 1):
		curr_pos = pos[val]
		curr_max = max(curr_max, curr_pos)
		curr_min = min(curr_min, curr_pos)
		if curr_max - curr_min + 1 == val:
			ans[val - 1] = '1'
	print(''.join(ans))


for t in range(int(input())):
	n = int(input())
	p = [int(x) for x in input().split()]
	a = [0] * n
	ans = ''
	left = n
	right = 0
	for i in range(n):
		a[p[i] - 1] = i
	for i in range(n):
		left = min(left, a[i])
		right = max(right, a[i])
		if right - left == i:
			ans += '1'
		else:
			ans += '0'
	print(ans)


for _ in range(int(input())):
	n = int(input())
	perm = list(map(int, input().split()))
	pos = [None] * (n + 1)
	for i in range(n):
		pos[perm[i]] = i
	l = n
	r = -1
	for i in range(1, n + 1):
		l = min(pos[i], l)
		r = max(pos[i], r)
		size = r - l + 1
		if i == size:
			print('1', end='')
		else:
			print('0', end='')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	ps = list(map(lambda x: (x[1], x[0]), list(enumerate(map(int, input().split())))))
	ps.sort()
	res = []
	mx = -1
	mn = 10 ** 19
	j = 0
	for (_, i) in ps:
		mx = max(i, mx)
		mn = min(i, mn)
		if mx - mn == j:
			res.append('1')
		else:
			res.append('0')
		j += 1
	print(''.join(res))


from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def iinp():
	return int(inp())

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

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

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

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def remadd(x, y):
	return 1 if x % y else 0

def ceil(a, b):
	return (a + b - 1) // b

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
for _ in range(int(inp())):
	n = iinp()
	arr = lmp()
	l = arr.index(1)
	r = l
	j = 1
	c = 1
	print('1', end='')
	while j < n:
		j += 1
		while c < j:
			if l > 0 and arr[l - 1] <= j:
				c += 1
				l -= 1
			elif r < n - 1 and arr[r + 1] <= j:
				c += 1
				r += 1
			else:
				break
		print('1' if c == j else '0', end='')
	print()


cases = int(input())
for t in range(cases):
	n = int(input())
	p = list(map(int, input().split()))
	i = 0
	j = n - 1
	s = ['0'] * n
	ss = sum(p)
	while i <= j:
		c = j - i + 1
		ss1 = c * (c + 1) // 2
		if ss1 == ss:
			s[c - 1] = '1'
		if p[i] < p[j]:
			ss -= p[j]
			j -= 1
		else:
			ss -= p[i]
			i += 1
	print(''.join(s))


for h in range(int(input())):
	a = int(input())
	l1 = list(map(int, input().split()))
	arr = [0] * a
	for i in range(a):
		arr[l1[i] - 1] = i
	l = a
	r = 0
	s = ''
	for i in range(a):
		l = min(l, arr[i])
		r = max(r, arr[i])
		if r - l == i:
			s += '1'
		else:
			s += '0'
	print(s)


from collections import Counter
from collections import defaultdict
import math
t = int(input())
for _ in range(0, t):
	n = int(input())
	a = list(map(int, input().split()))
	d = dict()
	if n == 1:
		print(1)
		continue
	for i in range(0, n):
		d[a[i]] = i + 1
	l = d[1]
	r = d[2]
	l = min(d[1], d[2])
	r = max(d[1], d[2])
	q = ['1']
	for i in range(2, n):
		if r - l < i:
			q.append('1')
		else:
			q.append('0')
		if d[i + 1] < l:
			l = d[i + 1]
		if d[i + 1] > r:
			r = d[i + 1]
	q.append('1')
	g = ''.join(q)
	print(g)


t = int(input())
while t:
	t -= 1
	n = int(input())
	arr = [int(s) for s in input().split()]
	ans = [-1 for i in range(n)]
	i = 0
	j = n - 1
	max_ele = n
	while i <= j:
		l = arr[i]
		r = arr[j]
		if l == max_ele:
			if ans[l - 1] == -1:
				ans[l - 1] = 1
			i += 1
		elif r == max_ele:
			if ans[r - 1] == -1:
				ans[r - 1] = 1
			j -= 1
		elif l > r:
			if ans[l - 1] == -1:
				length = j - i + 1
				for k in range(l, length):
					if ans[k - 1] == -1:
						ans[k - 1] = 0
					if ans[length - 1] == -1:
						ans[length - 1] = 1
			i += 1
		else:
			if ans[r - 1] == -1:
				length = j - i + 1
				for k in range(r, length):
					if ans[k - 1] == -1:
						ans[k - 1] = 0
					if ans[length - 1] == -1:
						ans[length - 1] = 1
			j -= 1
		max_ele = max_ele - 1
	for i in ans:
		print(i, end='')
	print()


import collections as cc
import sys
I = lambda : list(map(int, input().split()))
for tc in range(int(input())):
	(n,) = I()
	l = I()
	a = [0] * (n + 1)
	ans = '1'
	for i in range(n):
		a[l[i]] = i
	l = a[1]
	r = a[1]
	for i in range(2, n + 1):
		l = min(l, a[i])
		r = max(r, a[i])
		if r - l + 1 == i:
			ans += '1'
		else:
			ans += '0'
	print(ans)


t = int(input())
for i in range(t):
	s = int(input())
	w = []
	a = list(map(int, input().split()))
	p = [0] * s
	for i in range(s):
		p[a[i] - 1] = i + 1
	r = 0
	l = s
	for i in range(s):
		r = max(r, p[i])
		l = min(l, p[i])
		if r - l == i:
			w.append(1)
		else:
			w.append(0)
	print(*w, sep='')


for _ in range(int(input())):
	n = int(input())
	fuad = list(map(int, input().split()))
	indexofNum = [None] * n
	for i in range(n):
		indexofNum[fuad[i] - 1] = i
	mn = 10000000.0
	mx = -1
	ans = ['0'] * n
	for i in range(n):
		mn = min(mn, indexofNum[i])
		mx = max(mx, indexofNum[i])
		if mx - mn == i:
			ans[i] = '1'
	print(''.join(ans))


import sys
inf = float('inf')

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

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

def input():
	return sys.stdin.readline().strip()
T = int(input())
while T:
	n = int(input())
	Arr = get_array()
	if n == 1:
		print(1)
		T -= 1
		continue
	index = [0] * (n + 1)
	for i in range(n):
		index[Arr[i]] = i + 1
	mini = min(index[1], index[2])
	maxi = max(index[1], index[2])
	ans = ['1'] + ['0'] * (n - 1)
	for i in range(2, n + 1):
		mini = min(index[i], mini)
		maxi = max(maxi, index[i])
		if maxi - mini < i:
			ans[i - 1] = '1'
	print(''.join(ans))
	T -= 1


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	ind = [0] * (n + 1)
	for i in range(n):
		ind[a[i]] = i
	m = 1
	ma = ind[1]
	mi = ind[1]
	ans = '1'
	for i in range(n - 1):
		m += 1
		ma = max(ind[m], ma)
		mi = min(ind[m], mi)
		if ma - mi + 1 == m:
			ans += '1'
		else:
			ans += '0'
	print(ans)


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	arr = []
	for j in range(n):
		b = []
		b.append(a[j])
		b.append(j + 1)
		arr.append(b)
	arr.sort()
	ma = arr[0][1]
	mi = arr[0][1]
	for j in range(n):
		ma = max(ma, arr[j][1])
		mi = min(mi, arr[j][1])
		if ma - mi + 1 == arr[j][0]:
			print(1, end='')
		else:
			print(0, end='')
	print()


def solve():
	n = int(input())
	num = [0] + [int(x) for x in input().split()]
	pos = [0] * (n + 1)
	for i in range(1, n + 1):
		pos[num[i]] = i
	can = [0] * (n + 1)
	visit = [0] * (n + 1)
	(l, r) = (pos[1], pos[1])
	tmp = 1
	visit[1] = 1
	can[1] = 1
	for i in range(2, n + 1):
		while pos[i] < l:
			l -= 1
			visit[num[l]] = 1
		while r < pos[i]:
			r += 1
			visit[num[r]] = 1
		while tmp < n and visit[tmp + 1]:
			tmp += 1
		if tmp == i and r - l + 1 == i:
			can[i] = 1
	print(*can[1:], sep='')
t = int(input())
for i in range(t):
	solve()


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	dic = {}
	ans = []
	min = 1000000000
	max = 0
	for j in range(len(a)):
		dic[a[j]] = j + 1
	min = dic[1]
	max = dic[1]
	ans.append('1')
	for k in range(2, len(a)):
		if dic[k] > max:
			max = dic[k]
		if dic[k] < min:
			min = dic[k]
		if max - min - 1 == k - 2:
			ans.append('1')
		else:
			ans.append('0')
	if len(a) != 1:
		ans.append('1')
	print(str(''.join(ans)))


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')
import bisect
testcases = int(input())
for j in range(testcases):
	n = int(input())
	ints = list(map(int, input().split()))
	ind1 = ints.index(1)
	vall = []
	valr = []
	cumsum = 0
	maxsofar = 0
	for s in range(ind1 - 1, -1, -1):
		distance = abs(s - ind1)
		cumsum += ints[s]
		if ints[s] > maxsofar:
			maxsofar = ints[s]
		vall.append((distance, cumsum, maxsofar))
	maxsofar1 = 0
	cumsum1 = 0
	for s in range(ind1 + 1, n):
		distance1 = abs(s - ind1)
		if ints[s] > maxsofar1:
			maxsofar1 = ints[s]
		cumsum1 += ints[s]
		valr.append((distance1, cumsum1, maxsofar1))
	vall.sort(key=lambda x: x[0])
	valr.sort(key=lambda x: x[0])
	vall1 = [k[0] for k in vall]
	valr1 = [k[0] for k in valr]
	setty = set([1])
	for s in range(len(vall)):
		length = vall[s][0]
		summy = vall[s][1]
		if summy == vall[s][2] * (vall[s][2] + 1) // 2 - 1:
			setty.add(vall[s][2])
		else:
			needed = vall[s][2] - 1 - length
			if len(valr) > 0:
				valn = valr[max(min(bisect.bisect_left(valr1, needed), len(valr) - 1), 0)]
				if valn[1] + summy == vall[s][2] * (vall[s][2] + 1) // 2 - 1 and length + valn[0] == vall[s][2] - 1:
					setty.add(vall[s][2])
	for s in range(len(valr)):
		length = valr[s][0]
		summy = valr[s][1]
		if summy == valr[s][2] * (valr[s][2] + 1) // 2 - 1:
			setty.add(valr[s][2])
		else:
			needed = valr[s][2] - 1 - length
			if len(vall) > 0:
				valn = vall[max(min(bisect.bisect_left(vall1, needed), len(vall) - 1), 0)]
				if valn[1] + summy == valr[s][2] * (valr[s][2] + 1) // 2 - 1 and length + valn[0] == valr[s][2] - 1:
					setty.add(valr[s][2])
	outy = []
	for s in range(n):
		if s + 1 in setty:
			outy.append(str(1))
		else:
			outy.append(str(0))
	print(''.join(outy))


def inp():
	return [int(s) for s in input().split()]
for i in range(int(input())):
	n = int(input())
	str = input().split(' ')
	arr = {}
	for j in range(n):
		arr[int(str[j])] = j
	output = '1'
	l = arr[1]
	r = arr[1]
	for j in range(1, n):
		id = arr[j + 1]
		l = min(id, l)
		r = max(id, r)
		if r - l == j:
			output += '1'
		else:
			output += '0'
	print(output)


from sys import stdin, stdout
cases = int(stdin.readline().strip())
for caso in range(cases):
	n = int(stdin.readline().strip())
	s = list(map(int, stdin.readline().strip().split()))
	arr = [-1 for i in range(n + 1)]
	for i in range(n):
		arr[s[i]] = i
	l = arr[1]
	r = arr[1]
	ans = '1'
	for i in range(2, n + 1):
		if arr[i] > r:
			r = arr[i]
		if arr[i] < l:
			l = arr[i]
		if r - l + 1 == i:
			ans += '1'
		else:
			ans += '0'
	stdout.write('%s\n' % ans)


def solution(caso):
	resposta = []
	l_i = caso.index(1)
	l_s = l_i
	for m in range(1, len(caso) + 1):
		while l_i >= 0 and caso[l_i] <= m:
			l_i -= 1
		while l_s + 1 < len(caso) and caso[l_s + 1] <= m:
			l_s += 1
		if l_s - l_i == m:
			resposta.append('1')
		else:
			resposta.append('0')
	return resposta
n_casos = int(input())
casos = []
for i in range(n_casos):
	input()
	casos.append(list(map(int, input().split(' '))))
for caso in casos:
	print(''.join(solution(caso)))


for _ in range(int(input())):
	n = int(input())
	p = [0] + list(map(int, input().split()))
	d1 = dict()
	for i in range(1, n + 1):
		d1[p[i]] = i
	ans = [0] * (n + 1)
	(l, r) = (d1[1], d1[1])
	ans[1] = 1
	res = [0] * (n + 1)
	res[l] = 1
	count = 0
	for i in range(2, n + 1):
		count += 1
		if d1[i] < l:
			l = d1[i]
		elif d1[i] > r:
			r = d1[i]
		res[d1[i]] = 1
		if abs(r - l) == count:
			ans[i] = 1
	print(*ans[1:], sep='')


from math import floor, ceil
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	pos = dict()
	for (p, i) in enumerate(a):
		pos[i] = p
	minpos = [None] + [pos[1]] + [None] * (n - 1)
	maxpos = [None] + [pos[1]] + [None] * (n - 1)
	for i in range(2, n + 1):
		minpos[i] = min(minpos[i - 1], pos[i])
		maxpos[i] = max(maxpos[i - 1], pos[i])
	good = ['0'] * n
	for i in range(1, n + 1):
		if maxpos[i] - minpos[i] + 1 == i:
			good[i - 1] = '1'
	print(''.join(good))


from sys import stdin
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin

def ii():
	return int(stdin.readline())

def fi():
	return float(stdin.readline())

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

def fmi():
	return map(float, stdin.readline().split())

def li():
	return list(mi())

def lsi():
	x = list(stdin.readline())
	x.pop()
	return x

def si():
	return stdin.readline()
for _ in range(ii()):
	n = ii()
	a = li()
	p = [0] * (n + 1)
	ans = [0] * n
	ans[0] = ans[n - 1] = 1
	for i in range(n):
		p[a[i]] = i
	(mx, mn) = (-1, n + 1)
	for i in range(1, n + 1):
		mx = max(mx, p[i])
		mn = min(mn, p[i])
		if mx - mn + 1 == i:
			ans[i - 1] = 1
	print(*ans, sep='')


from collections import defaultdict
y = int(input())
for _ in range(y):
	n = int(input())
	d = defaultdict(int)
	l = list(map(int, input().split()))
	for i in range(n):
		d[l[i]] = i
	res = [0] * n
	for i in range(n):
		if i == 0:
			(m1, m2) = (d[1], d[1])
		else:
			if d[i + 1] < m1:
				m1 = d[i + 1]
			if d[i + 1] > m2:
				m2 = d[i + 1]
		if abs(m1 - m2) == i:
			res[i] = 1
	print(''.join(map(str, res)))


times = int(input())
for _ in range(times):
	n = int(input())
	p = input().split()
	q = [0] * n
	for (i, number) in enumerate(p):
		q[int(number) - 1] = i
	l = r = q[0]
	m = []
	for (k, i) in enumerate(q):
		if i < l:
			l = i
		elif i > r:
			r = i
		m.append('1' if r - l == k else '0')
	print(''.join(m))


import sys, collections
tc = int(sys.stdin.readline())
for _ in range(tc):
	n = int(sys.stdin.readline())
	arr = list(map(int, sys.stdin.readline().split()))
	ans = [0] * n
	max_pos = 0
	min_pos = n
	idx = [0] * n
	for i in range(n):
		idx[arr[i] - 1] = i
	for i in range(n):
		max_pos = max(max_pos, idx[i])
		min_pos = min(min_pos, idx[i])
		if max_pos - min_pos == i:
			ans[i] = 1
	print(''.join(map(str, ans)))


t = int(input())
for j in range(t):
	n = int(input())
	A = [int(s) for s in input().split(' ')]
	L = [0] * n
	for (i, x) in enumerate(A):
		num = x
		L[x - 1] = i
	l = r = L[0]
	m = []
	for (k, elm) in enumerate(L):
		if elm < l:
			l = elm
		elif elm > r:
			r = elm
		m.append('1' if r - l == k else '0')
	print(''.join(m))


import bisect
from sys import stdin, stdout
t = int(stdin.readline())
for ii in range(t):
	n = int(stdin.readline())
	ans = []
	a = list(map(int, stdin.readline().rstrip().split()))
	index = a.index(1)
	ans.append(1)
	final = []
	final.append(1)
	index1 = [0] * (n + 1)
	for i in range(n):
		index1[a[i]] = i
	glad = 0
	j = index - 1
	ans.append(1)
	j = 2
	left = index - 1
	f = [0] * (n + 1)
	i = index
	f[1] = 1
	current = index
	left = index - 1
	maxi = 1
	while len(final) != n and j <= n:
		if f[j] == 1:
			j += 1
			continue
		g = index1[j]
		for i in range(current + 1, g + 1):
			if f[a[i]] == 1:
				pass
			else:
				final.append(a[i])
				maxi = max(maxi, a[i])
				f[a[i]] = 1
				if len(final) == maxi:
					ans.append(maxi)
					j = maxi + 1
		current = max(current, g)
		for i in range(left, g - 1, -1):
			if f[a[i]] == 1:
				pass
			else:
				final.append(a[i])
				maxi = max(maxi, a[i])
				f[a[i]] = 1
				if len(final) == maxi:
					ans.append(maxi)
					j = maxi + 1
		current = max(current, g)
		left = min(left, g)
	ans.append(n)
	ans = set(ans)
	s = []
	for i in range(1, n + 1):
		if i in ans:
			s.append('1')
		else:
			s.append('0')
	ans = ''.join(s)
	stdout.write(ans)
	stdout.write('\n')


from sys import stdin, stdout
from math import gcd, ceil, sqrt
from collections import Counter
from bisect import bisect_left, bisect_right
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
tc = ii1()
for _ in range(tc):
	n = ii1()
	arr = iia()
	d = {}
	for i in range(n):
		d[arr[i]] = i
	res = '1'
	pos = [d[1], d[1]]
	for i in range(2, n + 1):
		if d[i] > pos[1]:
			pos[1] = d[i]
		if d[i] < pos[0]:
			pos[0] = d[i]
		if pos[1] - pos[0] + 1 == i:
			res += '1'
		else:
			res += '0'
	stdout.write(res + '\n')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	c = [1]
	e = []
	for i in range(len(a)):
		b.append(0)
	for i in range(1, len(a)):
		b[a[i] - 1] = i
	d = [b[0]]
	x = b[0]
	s = 1
	for i in range(1, len(a)):
		d.append(d[i - 1] + b[i])
		if b[i] < x:
			x = b[i]
		t = d[i] - (x - 1) * (i + 1)
		s = s + i + 1
		if t == s:
			c.append(1)
		else:
			c.append(0)
	p = ''.join([str(i) for i in c])
	print(p)


def arr_enu():
	return [[i + 1, int(x)] for (i, x) in enumerate(input().split())]
for i in range(int(input())):
	(n, a) = (int(input()), arr_enu())
	a.sort(key=lambda x: x[1])
	(ma, mi) = (a[0][0], a[0][0])
	out = '1'
	for j in range(1, n):
		ma = max(ma, a[j][0])
		mi = min(mi, a[j][0])
		if ma - mi == j:
			out += '1'
		else:
			out += '0'
	print(out)


import sys, math, itertools
from collections import Counter, deque, defaultdict
from bisect import bisect_left, bisect_right
mod = 10 ** 9 + 7
INF = float('inf')

def inp():
	return int(sys.stdin.readline())

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

class UnionFind:

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

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

	def union(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x == y:
			return
		if self.parents[x] > self.parents[y]:
			(x, y) = (y, x)
		self.parents[x] += self.parents[y]
		self.parents[y] = x

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

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

	def members(self, x):
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i) == root]

	def roots(self):
		return [i for (i, x) in enumerate(self.parents) if x < 0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()}
for _ in range(inp()):
	n = inp()
	a = inpl()
	d = {}
	uf = UnionFind(n)
	for (i, x) in enumerate(a):
		d[x] = i
	ok = [False] * n
	ok[d[1]] = True
	res = ['1'] * n
	one = d[1]
	for x in range(2, n + 1):
		now = d[x]
		ok[now] = True
		if now != 0 and ok[now - 1]:
			uf.union(now - 1, now)
		if now != n - 1 and ok[now + 1]:
			uf.union(now + 1, now)
		if uf.size(one) != x:
			res[x - 1] = '0'
	print(''.join(res))


from sys import *
for u in range(int(stdin.buffer.readline())):
	n = int(stdin.buffer.readline())
	l = list(map(int, stdin.buffer.readline().split()))
	d = [0] * n
	for i in range(n):
		d[l[i] - 1] = i
	(m, x) = (10 ** 18, 0)
	c = 0
	dd = []
	for i in d:
		m = min(m, i)
		x = max(x, i)
		c = c + i
		s = x * (x + 1) // 2 - m * (m - 1) // 2
		if s == c:
			dd.append('1')
		else:
			dd.append('0')
	print(''.join(dd))


import sys
import math

def kek():
	t = int(input())
	for _ in range(t):
		sys.stdin.readline()
		a = sys.stdin.readline().split()
		p = [0] * len(a)
		for i in range(len(a)):
			p[int(a[i]) - 1] = i + 1
		minn = math.inf
		maxx = 0
		for i in range(len(p)):
			minn = min(minn, p[i])
			maxx = max(maxx, p[i])
			if maxx - minn == i:
				sys.stdout.write('1')
			else:
				sys.stdout.write('0')
		sys.stdout.write('\n')
kek()


def solve():
	s = input()
	if 'aa' in s or 'bb' in s or 'cc' in s:
		print(-1)
		return
	syms = s + '@'
	ans = ['@']
	for (i, sym) in enumerate(s):
		if sym != '?':
			ans.append(sym)
			continue
		for x in 'abc':
			if x != ans[-1] and x != syms[i + 1]:
				ans.append(x)
				break
	print(''.join(ans[1:]))

def solveb():
	n = int(input())
	perm = [int(x) for x in input().split()]
	num___idx = [-1 for _ in range(n + 1)]
	for (i, num) in enumerate(perm):
		num___idx[num] = i
	curr_max = -1
	curr_min = 2 * n
	num___pretty = [0 for _ in range(n + 1)]
	for num in range(1, n + 1):
		curr_max = max(num___idx[num], curr_max)
		curr_min = min(num___idx[num], curr_min)
		if curr_max - curr_min + 1 == num:
			num___pretty[num] = 1
	print(*num___pretty[1:], sep='')
for _ in range(int(input())):
	solveb()


I = input
for _ in range(int(I())):
	n = int(I())
	a = list(map(int, I().split(' ')))
	pos = [i[0] for i in sorted(enumerate(a), key=lambda x: x[1])]
	ans = ['0' for i in range(n)]
	ans[0] = '1'
	t1 = []
	mi = pos[0]
	ma = pos[0]
	for i in range(2, n + 1):
		if mi > pos[i - 1]:
			mi = pos[i - 1]
		if ma < pos[i - 1]:
			ma = pos[i - 1]
		t1.append([mi, ma])
	w = 0
	for i in range(2, n + 1):
		if i == 2:
			if pos[1] == pos[0] - 1 or pos[1] == pos[0] + 1:
				ans[1] = '1'
		else:
			x = t1[w][0]
			x1 = t1[w][1]
			x = min(x, pos[i - 1])
			x1 = max(x1, pos[i - 1])
			w += 1
			if x1 - x + 1 == i:
				ans[i - 1] = '1'
	print(''.join(ans))


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		tab = list(map(int, input().split()))
		ind = [0] * n
		for x in range(n):
			ind[tab[x] - 1] = x
		l = n + 1
		r = 0
		for x in range(n):
			l = min(l, ind[x])
			r = max(r, ind[x])
			if r - l == x:
				print(1, end='')
			else:
				print(0, end='')
		print()
main()


for _ in ' ' * int(input()):
	a = int(input())
	d = dict(zip(map(int, input().split()), range(1, a + 1)))
	l = 1
	r = a
	z = [0] * a
	k = d[1]
	for i in range(a, 0, -1):
		if l <= d[i] <= r:
			if r - l + 1 == i:
				z[i - 1] = 1
			else:
				z[i - 1] = 0
			if d[i] < k:
				l = d[i] + 1
			else:
				r = d[i] - 1
	print(*z, sep='')


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		arr = list(map(int, input().split()))
		ordered = [x for (_, x) in sorted(zip(arr, list(range(len(arr)))), key=lambda x: x[0])]
		count = [False for _ in range(n)]
		count[ordered[0]] = True
		min_index = ordered[0]
		max_index = ordered[0]
		p1 = ordered[0]
		p2 = ordered[0]
		rv = ['0' for _ in range(n)]
		rv[0] = '1'
		for i in range(1, len(ordered)):
			count[ordered[i]] = True
			if max_index < ordered[i]:
				max_index = ordered[i]
			elif min_index > ordered[i]:
				min_index = ordered[i]
			while p1 < n:
				if not count[p1]:
					break
				p1 += 1
			p1 -= 1
			while p2 >= 0:
				if not count[p2]:
					break
				p2 -= 1
			p2 += 1
			if p1 == max_index and p2 == min_index:
				rv[arr[ordered[i]] - 1] = '1'
		print(''.join(rv))
main()


for _ in range(int(input())):
	n = int(input())
	a = input().split()
	l = r = a.index('1')
	for i in range(1, n):
		b = 1
		while b == 1:
			b = 0
			if l > 0 and int(a[l - 1]) <= i:
				l -= 1
				b = 1
			if r < n - 1 and int(a[r + 1]) <= i:
				r += 1
				b = 1
		if r - l + 1 == i:
			print('1', end='')
		else:
			print('0', end='')
	print('1')


def beautiful_numbers():
	n = int(input())
	permutation = [int(x) for x in input().split()]
	position = [0] * n
	for i in range(n):
		position[permutation[i] - 1] = i
	mini = maxi = position[0]
	answer = ''
	for i in range(n):
		if mini > position[i]:
			mini = position[i]
		if maxi < position[i]:
			maxi = position[i]
		if maxi - mini == i:
			answer += '1'
		else:
			answer += '0'
	return answer
t = int(input())
for _ in range(t):
	print(beautiful_numbers())


def vals(nums):
	nums = nums.split()
	nums = [int(char) for char in nums]
	vis = []
	if len(nums) == 1:
		print(1)
	elif len(nums) == 2:
		print(11)
	else:
		for i in range(len(nums)):
			vis.append(0)
		for i in range(len(nums)):
			vis[nums[i] - 1] = i
		min = vis[0]
		max = vis[0]
		beauti = []
		beauti.append(1)
		for i in range(1, len(vis)):
			if vis[i] < min:
				min = vis[i]
			elif vis[i] > max:
				max = vis[i]
			if max - min == i:
				beauti.append(1)
			else:
				beauti.append(0)
		beauti = [str(char) for char in beauti]
		print(''.join(beauti))
c = []
a = int(input())
for i in range(a):
	inp = eval(input())
	val = input()
	c.append(val)
for i in range(a):
	vals(c[i])


from collections import defaultdict
for _ in range(int(input())):
	Dict = defaultdict(int)
	AnsDict = defaultdict(int)
	n = int(input())
	List = [int(x) for x in input().split()]
	for i in range(n):
		Dict[List[i]] = i
	Max = Min = Dict[1]
	AnsDict[1] = '1'
	for i in range(2, n + 1):
		if abs(Dict[i] - Min) < i and abs(Dict[i] - Max) < i and (Max - Min < i):
			Min = min(Min, Dict[i])
			Max = max(Max, Dict[i])
			AnsDict[i] = '1'
		else:
			Min = min(Min, Dict[i])
			Max = max(Max, Dict[i])
			AnsDict[i] = '0'
	S = str()
	for i in range(1, n + 1):
		S += AnsDict[i]
	print(S)


from sys import stdin

def rl():
	return [int(w) for w in stdin.readline().split()]
(k,) = rl()
for _ in range(k):
	(n,) = rl()
	p = rl()
	q = [0] * n
	for (i, x) in enumerate(p):
		q[x - 1] = i
	l = r = q[0]
	m = []
	for (k, i) in enumerate(q):
		if i < l:
			l = i
		elif i > r:
			r = i
		m.append('1' if r - l == k else '0')
	print(''.join(m))


t = int(input())
i = 0
while i < t:
	n = int(input())
	arr = list(map(int, input().split()))
	diff = [0] * n
	for x in range(n):
		diff[arr[x] - 1] = x
	result = '1'
	maxx = diff[0]
	minn = diff[0]
	for x in range(1, n):
		maxx = max(maxx, diff[x])
		minn = min(minn, diff[x])
		a = maxx - minn
		if a > x:
			result = result + '0'
		else:
			result = result + '1'
	print(result)
	i = i + 1


import sys
I = sys.stdin.buffer.readline

def give(a, n):
	p = n * (2 * a + n - 1)
	return p // 2
for _ in range(int(I())):
	n = int(I())
	p = list(map(int, I().split()))
	a = [0] * (n + 1)
	for (i, x) in enumerate(p):
		a[x] = i
	i = 1
	s = 0
	m = n
	while i <= n:
		s += a[i]
		m = min(m, a[i])
		print(int(s == give(m, i)), end='')
		i += 1
	print()


from sys import stdin
input = lambda : stdin.readline().rstrip('\r\n')
input_a = lambda fun: map(fun, stdin.readline().split())

def read():
	n = int(input())
	a = list(input_a(int))
	return (n, a)

def solve(n, a):
	ind = [0] * n
	res = [0] * n
	for i in range(n):
		ind[a[i] - 1] = i
	res[0] = 1
	left = right = ind[0]
	for i in range(1, n):
		pos = ind[i]
		left = min(left, pos)
		right = max(right, pos)
		if right - left == i:
			res[i] = 1
	return res
for t in range(int(input())):
	result = solve(*read())
	print(*result, sep='')


T = int(input())
for _ in range(T):
	N = int(input())
	l = [-1] + list(map(int, input().split()))
	I = [0 for i in range(N + 1)]
	V = [0 for i in range(N + 1)]
	for i in range(1, N + 1):
		I[l[i]] = i
	j = 2
	t = 1
	V[1] = 1
	L = I[1]
	R = I[1]
	print(1, end='')
	while j <= N:
		if V[j] == 1:
			if t == j:
				print(1, end='')
				j += 1
				continue
		else:
			while I[j] < L:
				L -= 1
				V[l[L]] = 1
				t += 1
			while R < I[j]:
				R += 1
				V[l[R]] = 1
				t += 1
			if t == j:
				print(1, end='')
				j += 1
				continue
		print(0, end='')
		j += 1
	print()


I = lambda : int(input())
ID = lambda : map(int, input().split())
IL = lambda : list(ID())
t = I()
for _ in range(t):
	n = I()
	a = IL()
	ans = [0] * n
	p = n + 1
	i = 0
	j = n - 1
	ans[0] = 1
	ans[n - 1] = 1
	while j > i:
		if a[i] > a[j]:
			if a[i] < p:
				p = a[i]
			i += 1
		else:
			if a[j] < p:
				p = a[j]
			j -= 1
		if j - i == p - 2:
			ans[j - i] = 1
	q = ''
	print(q.join((str(_) for _ in ans)))


class UnionFind:

	def __init__(self, n):
		self.par = [-1] * n
		self.rank = [0] * n

	def Find(self, x):
		if self.par[x] < 0:
			return x
		else:
			self.par[x] = self.Find(self.par[x])
			return self.par[x]

	def Unite(self, x, y):
		x = self.Find(x)
		y = self.Find(y)
		if x != y:
			if self.rank[x] < self.rank[y]:
				self.par[y] += self.par[x]
				self.par[x] = y
			else:
				self.par[x] += self.par[y]
				self.par[y] = x
				if self.rank[x] == self.rank[y]:
					self.rank[x] += 1

	def Same(self, x, y):
		return self.Find(x) == self.Find(y)

	def Size(self, x):
		return -self.par[self.Find(x)]
import sys
import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
t = int(input())
for _ in range(t):
	n = int(input())
	P = list(map(int, input().split()))
	if n == 1:
		print(1)
		continue
	P = [p - 1 for p in P]
	A = [-1] * n
	for (i, p) in enumerate(P):
		A[p] = i
	uf = UnionFind(n)
	ans = []
	for (i, a) in enumerate(A):
		if a != 0 and a != n - 1:
			if P[a - 1] < i:
				uf.Unite(a - 1, a)
			if P[a + 1] < i:
				uf.Unite(a + 1, a)
		elif a == 0:
			if P[a + 1] < i:
				uf.Unite(a + 1, a)
		elif P[a - 1] < i:
			uf.Unite(a - 1, a)
		if uf.Size(a) >= i + 1:
			ans.append('1')
		else:
			ans.append('0')
	print(''.join(ans))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	pos_of = [0] * n
	for i in range(n):
		pos_of[a[i] - 1] = i
	l = pos_of[0]
	r = pos_of[0]
	output = ''
	for i in range(n):
		if pos_of[i] > r:
			r = pos_of[i]
		if pos_of[i] < l:
			l = pos_of[i]
		if r - l == i:
			output += '1'
		else:
			output += '0'
	print(output)


t = int(input())
for i in range(t):
	n = int(input())
	permut = list(map(int, input().split()))
	location = [0] * n
	answer = ''
	for index in range(n):
		location[permut[index] - 1] = index
	maks = location[0]
	mini = location[0]
	for j in range(n):
		if location[j] > maks:
			maks = location[j]
		if location[j] < mini:
			mini = location[j]
		if maks - mini == j:
			answer += '1'
		else:
			answer += '0'
	print(answer)


num_de_casos = int(input())
for i in range(num_de_casos):
	tamanho = int(input())
	permutacao = list(map(int, input().split()))
	dicionario = {}
	esquerda = tamanho
	direita = 0
	for j in range(tamanho):
		dicionario[permutacao[j]] = j
	resposta = ''
	for j in range(1, tamanho + 1):
		esquerda = min(esquerda, dicionario[j])
		direita = max(direita, dicionario[j])
		if direita - esquerda + 1 == j:
			resposta += '1'
		else:
			resposta += '0'
	print(resposta)


def sleft(ls: list, d: int):
	t = 0
	for i in ls[::-1]:
		if i < d:
			t += 1
		else:
			return t
	return t

def sright(ls: list, d: int):
	t = 0
	for i in ls:
		if i < d:
			t += 1
		else:
			return t
	return t

def search(s: list):
	if len(s) == 1:
		if s[0] == 1:
			return '1'
		else:
			return '0'
	l = len(s)
	ans = ['0' for i in range(l)]
	for (i, num) in enumerate(s):
		j = 0
		if i != 0:
			j += sleft(s[:i], num)
		if i != l - 1:
			j += sright(s[i + 1:], num)
		if j == num - 1:
			ans[num - 1] = '1'
		else:
			ans[num - 1] = '0'
	return ''.join(ans)

def alt(s: set, lr: int):
	s = [-1] + sorted(s) + [lr]
	jd = 0
	for i in range(1, len(s)):
		if s[i] != s[i - 1] + 1:
			jd += 1
		if jd == 2:
			return False
	return True

def search2(s: list, l: int):
	if len(s) == 1:
		return '1'
	d = {s.index(l)}
	out = '1'
	for i in range(l - 1, 0, -1):
		if alt(d, l):
			out += '1'
		else:
			out += '0'
		p = s.index(i)
		d.add(p)
	return out[::-1]

def search3(s: list, l: int):
	if l == 1:
		return '1'
	if l == 2:
		return '11'
	out = '1'
	large = s.index(1)
	small = s.index(1)
	dic = sorted(enumerate(s), key=lambda x: x[1])[1:]
	for i in dic:
		mid = i[0]
		if mid > large:
			large = mid
		if mid < small:
			small = mid
		if large - small == i[1] - 1:
			out += '1'
		else:
			out += '0'
	return out
n = int(input())
out = []
for i in range(n):
	a = int(input())
	l = list(map(int, input().split(' ')))
	out.append(search3(l, a))
for i in out:
	print(i)


for _ in range(int(input())):
	n = int(input())
	p = list(map(int, input().split()))
	d = {}
	l = n
	r = 0
	for j in range(n):
		d[p[j]] = j
	res = ''
	for j in range(1, n + 1):
		l = min(l, d[j])
		r = max(r, d[j])
		if r - l + 1 == j:
			res += '1'
		else:
			res += '0'
	print(res)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	p = [0] * n
	for i in range(n):
		p[l[i] - 1] = i
	(a, r) = (n, 0)
	ans = ''
	for i in range(n):
		a = min(a, p[i])
		r = max(r, p[i])
		if r - a == i:
			ans += '1'
		else:
			ans += '0'
	print(ans)


import sys
input = sys.stdin.buffer.readline
from collections import defaultdict

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

def main():
	Q = int(input())
	for i in range(Q):
		N = int(input())
		A = getlist()
		B = []
		for j in range(N):
			B.append([A[j], j])
		B = sorted(B)
		ans = ['0'] * N
		MAX = 0
		MIN = N
		for j in range(N):
			x = B[j][1]
			MAX = max(MAX, x)
			MIN = min(MIN, x)
			if MAX - MIN == j:
				ans[j] = '1'
		print(''.join(ans))
main()


from math import ceil
from math import factorial
import collections
ii = lambda : int(input())
iia = lambda : list(map(int, input().split()))
isa = lambda : list(input().split())
t = ii()
for i in range(t):
	n = ii()
	a = iia()
	x = [0] * n
	for i in range(n):
		x[i] = [a[i], i + 1]
	x = sorted(x)
	y = [0 for i in range(n)]
	s = ''
	maxi = 10000000
	mini = -10000000
	for i in range(n):
		if i == 0:
			s += '1'
			y[i] = x[i][1]
			maxi = y[i]
			mini = y[i]
		else:
			y[i] = x[i][1]
			if maxi < y[i]:
				maxi = y[i]
			elif mini > y[i]:
				mini = y[i]
			if maxi - mini == i:
				s += '1'
			else:
				s += '0'
	print(s)


from sys import stdin
input = stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	start = 0
	for (i, v) in enumerate(a):
		if v == 1:
			start = i
			break
	ans = [0] * -~n
	ans[n - 1] = 1
	mx = 1
	l = start
	r = start

	def move(x):
		global l, r, mx
		if x:
			mx = max(a[r + 1], mx)
			r += 1
		else:
			mx = max(a[l - 1], mx)
			l -= 1
	while mx < n:
		if mx == r - l + 1:
			ans[mx - 1] = 1
		if l == 0:
			move(1)
		elif r == n - 1:
			move(0)
		elif a[l - 1] > a[r + 1]:
			move(1)
		else:
			move(0)
	print(''.join(map(str, ans[:n])))


I = input
for _ in [0] * int(I()):
	n = int(I())
	a = [0] * n
	i = j = m = 0
	r = ''
	for x in map(int, I().split()):
		a[x - 1] = i
		i += 1
	for x in a:
		n = min(n, x)
		m = max(m, x)
		r += '10'[m - n > j]
		j += 1
	print(r)


def solve(permutation):
	aux = set([])
	response = ''
	indexes = {}
	for i in range(len(permuation)):
		indexes[permuation[i]] = i
	l = 0
	while permuation[l] != 1:
		l += 1
	r = l
	current = 2
	response += '1'
	while len(response) != len(permuation):
		aux_l = l
		aux_r = r
		while l >= 0 or r < len(permuation):
			if aux_l <= indexes[current] <= aux_r:
				if r - l + 1 == current:
					response += '1'
				else:
					response += '0'
				current += 1
				break
			elif r < len(permuation) and permuation[r] == current:
				l = aux_l
				if r - l + 1 == current:
					response += '1'
				else:
					response += '0'
				current += 1
				break
			elif l >= 0 and permutation[l] == current:
				r = aux_r
				if r - l + 1 == current:
					response += '1'
				else:
					response += '0'
				current += 1
				break
			if r < len(permutation) - 1:
				r += 1
			if l > 0:
				l -= 1
	return response
t = int(input())
for i in range(t):
	n = input()
	permuation = list(map(int, input().split()))
	print(solve(permuation))


from sys import stdin, stdout
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	p = [0] * n
	a = list(map(int, input().split()))
	for i in range(n):
		p[a[i] - 1] = i
	l = n
	r = 0
	for i in range(n):
		l = min(l, p[i])
		r = max(r, p[i])
		if r - l == i:
			print('1', end='')
		else:
			print('0', end='')
	print()


from math import *
from collections import Counter, defaultdict, deque
from sys import stdin, stdout
input = stdin.readline
I = lambda : int(input())
M = lambda : map(int, input().split())
LI = lambda : list(map(int, input().split()))
for _ in range(I()):
	n = I()
	a = LI()
	d = {}
	for i in range(n):
		d[a[i]] = i
	s = ''
	mi = n
	ma = 0
	for i in range(1, n + 1):
		mi = min(mi, d[i])
		ma = max(ma, d[i])
		if ma - mi == i - 1:
			print('1', end='')
		else:
			print('0', end='')
	print()


import sys

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

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())
qwe = dict()
alb = 'abc?'
for a in alb:
	for b in alb:
		for c in alb:
			cnt = [0, 0, 0]
			for d in range(3):
				if a == alb[d]:
					cnt[d] += 1
				if b == alb[d]:
					cnt[d] += 1
				if c == alb[d]:
					cnt[d] += 1
			qwe[a + b + c] = chr(ord('a') + cnt.index(min(cnt)))

def solve():
	n = mint()
	p = list(mints())
	a = []
	prev = int(1000000000.0)
	for i in range(n):
		if p[i] < prev:
			a.append((p[i], i))
			if p[i] == 1:
				break
	prev = -1
	for i in range(i, n):
		if p[i] > prev:
			a.append((p[i], i))
	a.sort()
	c = [0] * (n + 2)
	res = [0] * n
	l = a[0][1]
	r = a[0][1]
	c[1] = 1
	pos = 1
	res[0] = 1
	for (_, j) in a:
		while j > r:
			r += 1
			c[p[r]] += 1
		while j < l:
			l -= 1
			c[p[l]] += 1
		while c[pos + 1] == 1:
			pos += 1
		if pos == r - l + 1:
			res[pos - 1] = 1
	print(''.join(map(str, res)))
for t in range(mint()):
	solve()


t = int(input())
for x in range(t):
	n = int(input())
	p = [n + 10] + list(map(int, input().split()))
	p.append(n + 10)
	i = 0
	ind1 = 0
	while i < n + 2:
		if p[i] == 1:
			ind1 = i
			i = n
		i += 1
	ind2 = ind1
	d = 1
	maks = 1
	answer = ''
	while d < n:
		if maks <= d:
			answer += '1'
		else:
			answer += '0'
		a = p[ind1 - 1]
		b = p[ind2 + 1]
		if a < b:
			ind1 -= 1
			if maks < a:
				maks = a
		else:
			ind2 += 1
			if maks < b:
				maks = b
		d += 1
	answer += '1'
	print(answer)


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	v = [0] * n
	s = '1'
	m = 0
	a = list(map(int, input().split()))
	print('1', end='')
	for i in range(n):
		v[a[i] - 1] = i + 1
	r = l = p = v[0]
	for i in range(1, n):
		if v[i] > r:
			r = v[i]
		elif v[i] < l:
			l = v[i]
		if r - l == i:
			print('1', end='')
		else:
			print('0', end='')
	print()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	x = [0] * (n + 1)
	for i in range(n):
		p = a[i]
		x[p] = i
	mn = x[1]
	mx = x[1]
	s = list()
	s.append(1)
	for i in range(2, n + 1):
		g = x[i]
		mn = min(mn, g)
		mx = max(mx, g)
		diff = mx - mn + 1
		if diff > i:
			s.append(0)
		else:
			s.append(1)
	for i in range(n):
		print(s[i], end='')
	print()


from sys import stdin
import math

def input():
	return stdin.buffer.readline()
t = int(input())
for _ in range(t):
	n = int(input())
	txt = list(map(int, input().split()))
	perm = [0] * n
	for i in range(len(txt)):
		perm[txt[i] - 1] = i
	msum = 0
	mmin = math.inf
	mmax = -1
	ans = []
	for p in perm:
		mmin = min(mmin, p)
		mmax = max(mmax, p)
		msum += p
		ssum = mmax * (mmax + 1) / 2 - (mmin - 1) * mmin / 2
		if msum == ssum:
			ans.append(1)
		else:
			ans.append(0)
	for a in ans:
		print(a, end='')
	print()


import sys
input = sys.stdin.readline
from operator import itemgetter

def main():
	t = int(input())
	for _ in range(t):
		N = int(input())
		P = [[int(x), i] for (i, x) in enumerate(input().split())]
		P_sorted = sorted(P, key=itemgetter(0))
		ma = -1
		mi = N + 1
		ans = []
		for i in P_sorted:
			ma = max(ma, i[1])
			mi = min(mi, i[1])
			if ma - mi + 1 == i[0]:
				ans.append(1)
			else:
				ans.append(0)
		print(''.join(map(str, ans)))
main()


t = int(input())
for _ in range(0, t):
	n = int(input())
	a = list(map(int, input().strip().split(' ')))
	b = {}
	for i in range(0, n):
		b[a[i]] = i
	c = list(b.items())
	c.sort()
	x = []
	m = ma = c[0][1]
	for i in range(0, n):
		m = min(m, c[i][1])
		ma = max(ma, c[i][1])
		if ma - m == i:
			x.append(1)
		else:
			x.append(0)
	for i in range(0, n):
		print(x[i], end='')
	print()


for step in range(int(input())):
	n = int(input())
	A = [int(i) for i in input().split()]
	index = [0] * (n + 1)
	for i in range(n):
		index[A[i]] = i
	Ans = ''
	pos_min = index[1]
	pos_max = index[1]
	for i in range(1, n + 1):
		pos_m = index[i]
		pos_min = min(pos_min, pos_m)
		pos_max = max(pos_max, pos_m)
		if pos_max - pos_min + 1 == i:
			Ans += '1'
		else:
			Ans += '0'
	print(Ans)


for _ in range(int(input())):
	s = '1'
	n = int(input())
	m = [0] * n
	l = list(map(int, input().split()))
	for i in range(n):
		m[l[i] - 1] = i
	minn = m[0]
	maxx = m[0]
	for i in range(1, n):
		minn = min(minn, m[i])
		maxx = max(maxx, m[i])
		if maxx - minn == i:
			s += '1'
		else:
			s += '0'
	print(s)


def fastio():
	import sys
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()
MOD = 10 ** 9 + 7
INF = 10 ** 20
I = lambda : list(map(int, input().split()))
from collections import defaultdict as dd
from math import gcd
(t,) = I()
while t:
	t -= 1
	(n,) = I()
	a = I()
	idx = [0] * (n + 1)
	for i in range(n):
		idx[a[i]] = i
	v = [0] * (n + 1)
	count = 1
	ans = ['0'] * n
	ans[0] = '1'
	v[1] = 1
	ml = idx[1]
	mr = idx[1]
	for j in range(2, n + 1):
		i = idx[j]
		x = idx[j - 1]
		(i, x) = (min(i, x), max(i, x))
		if not ml <= i <= x <= mr:
			for k in range(i, ml):
				if not v[a[k]]:
					v[a[k]] = 1
					count += 1
			for k in range(mr, x + 1):
				if not v[a[k]]:
					v[a[k]] = 1
					count += 1
		ml = min(ml, i)
		mr = max(mr, x)
		if count == j:
			ans[j - 1] = '1'
	print(''.join(ans))


import sys, math, heapq, copy
from sys import stdin, stdout
from collections import defaultdict, deque
from bisect import bisect_left, bisect_right
from functools import cmp_to_key
from itertools import permutations, combinations, combinations_with_replacement
mod = 1000000007

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

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

def get_float():
	return float(sys.stdin.readline().strip())

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

def get_strs():
	return map(str, sys.stdin.readline().strip().split())

def get_floats():
	return map(float, sys.stdin.readline().strip().split())

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

def list_strs():
	return list(map(str, sys.stdin.readline().strip().split()))

def list_floats():
	return list(map(float, sys.stdin.readline().strip().split()))

def print(value='', end='\n'):
	stdout.write(str(value) + end)
t = get_int()
for _ in range(t):
	n = get_int()
	l = list_ints()
	l = [[l[i], i] for i in range(n)]
	l.sort()
	minimum = math.inf
	maximum = -math.inf
	for i in range(n):
		minimum = min(minimum, l[i][1])
		maximum = max(maximum, l[i][1])
		if maximum - minimum == i:
			print(1, end='')
		else:
			print(0, end='')
	print()


n = int(input())
for j in range(n):
	m = int(input())
	L = [int(e) for e in input().strip().split()]
	L = [200002] + L + [200002]
	idx = L.index(1)
	i_left = i_right = idx
	max_value = 1
	s = '1'
	for i in range(1, m):
		if L[i_left - 1] < L[i_right + 1]:
			i_left -= 1
			max_value = max(max_value, L[i_left])
		else:
			i_right += 1
			max_value = max(max_value, L[i_right])
		if max_value - 1 == i:
			s += '1'
		else:
			s += '0'
	print(s)


t = int(input())
consultas = []
saida = []
i = 0
while i < t:
	consultas.append(int(input()))
	consultas.append(input().split())
	i += 1
j = 0
while j < len(consultas) - 1:
	n = consultas[j]
	lista = consultas[j + 1]
	mapa = {}
	res = ['0'] * n
	res[0] = '1'
	for k in range(n):
		mapa[lista[k]] = k
	l = mapa['1']
	r = mapa['1']
	for i in range(2, n + 1):
		l = min(l, mapa[str(i)])
		r = max(r, mapa[str(i)])
		if r - l + 1 == i:
			res[i - 1] = '1'
	saida.append(res)
	j += 2
for e in saida:
	print(''.join(e))


def mi():
	return map(int, input().split())
for _ in range(int(input())):
	n = int(input())
	a = list(mi())
	t = a.index(1)
	dist = [0] * (n + 1)
	dic = [0] * n
	for i in range(n):
		dist[a[i]] = abs(t - i)
		dic[i] = [a[i], i]
	dic.sort()
	lm = dic[0][1]
	rm = dic[0][1]
	print(1, end='')
	for i in range(1, n):
		if dic[i][1] < lm:
			lm = dic[i][1]
		if dic[i][1] > rm:
			rm = dic[i][1]
		if rm - lm < i + 1:
			print(1, end='')
		else:
			print(0, end='')
	print()


import math
for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	start = ar.index(1)
	end = start
	ans = [1]
	s = 1
	m = 2
	if n == 1:
		print(1)
		continue
	while True:
		(p, q) = (10000000, 10000000)
		if start - 1 >= 0:
			p = ar[start - 1]
		if end + 1 < n:
			q = ar[end + 1]
		if p > q:
			s += q
			end += 1
		elif p < q:
			s += p
			start -= 1
		if m * (m + 1) // 2 == s:
			ans.append(1)
		else:
			ans.append(0)
		if start == 0 and end == n - 1:
			break
		m += 1
	print(''.join((str(i) for i in ans)))


import os
import sys
from io import BytesIO, IOBase
from collections import Counter
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))

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

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

def main():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		done = [0] * (n + 1)
		d = [[-1, -1]]
		for i in range(n):
			d.append([a[i], i])
		d.sort()
		l = d[1][1]
		r = d[1][1]
		done[1] = 1
		ans = [0] * (n + 1)
		ans[1] = 1
		now = 2
		for i in range(1, n):
			if d[i][1] < l:
				for j in range(l - 1, d[i][1] - 1, -1):
					done[a[j]] = 1
				l = d[i][1]
			elif d[i][1] > r:
				for j in range(r + 1, d[i][1] + 1):
					done[a[j]] = 1
				r = d[i][1]
			while now < n and done[now]:
				now += 1
			if now > i and r - l + 1 == i:
				ans[i] = 1
		ans[n] = 1
		for i in range(1, n + 1):
			print(ans[i], end='')
		print('')
	return
main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	i = a.index(1)
	ans = [0] * n
	(ans[0], j) = (1, i)
	for k in range(2, n + 1):
		while i >= 0 and a[i] <= k:
			i -= 1
		while j < n and a[j] <= k:
			j += 1
		if j - i - 1 == k:
			ans[k - 1] = 1
	print(''.join(map(str, ans)))


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	st = []
	st.append(arr[0])
	r1 = [0] * (n + 1)
	r2 = [1] * (n + 1)
	r1[arr[0]] = 0
	for i in range(1, n):
		while len(st) and st[-1] < arr[i]:
			r1[arr[i]] += r1[st[-1]] + 1
			st.pop()
		st.append(arr[i])
	r2[arr[n - 1]] = 1
	st = []
	st.append(arr[n - 1])
	for i in range(n - 2, -1, -1):
		while len(st) and st[-1] < arr[i]:
			r2[arr[i]] += r2[st[-1]]
			st.pop()
		st.append(arr[i])
	for i in range(1, n + 1):
		if r1[i] + r2[i] == i:
			print(1, end='')
		else:
			print(0, end='')
	print()


for _ in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	index = {}
	res = [0] * (n + 1)
	for i in range(n):
		index[li[i]] = i + 1
	low = high = index[1]
	for i in range(1, n + 1):
		low = min(low, index[i])
		high = max(high, index[i])
		if high - low + 1 == i:
			res[i] = 1
	print(''.join([str(i) for i in res[1:]]))


import os
import operator
from collections import defaultdict
import sys
from io import BytesIO, IOBase
import bisect

def main():
	for _ in range(int(input())):
		n = int(input())
		ans = [0] * n
		arr = [int(k) for k in input().split()]
		pos = [0] * (n + 1)
		for i in range(n):
			pos[arr[i]] = i
		l = 10 ** 6 + 1
		r = 0
		for i in range(1, n + 1):
			l = min(l, pos[i])
			r = max(r, pos[i])
			if r - l + 1 == i:
				ans[i - 1] = '1'
			else:
				ans[i - 1] = '0'
		print(''.join(ans))
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 T in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	pos = [0] * (n + 1)
	j = 1
	for i in arr:
		pos[i] = j
		j += 1
	min1 = 10 ** 18
	max1 = 0
	ans = ['0'] * n
	for i in range(1, n + 1):
		min1 = min(min1, pos[i])
		max1 = max(max1, pos[i])
		if max1 - min1 + 1 == i:
			ans[i - 1] = '1'
	print(''.join(ans))


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(i) for i in input().split()]
	cur = [0] * n
	check = [1] * n
	start = arr.index(1)
	i = start - 1
	j = start + 1
	cur[0] = 1
	temp = 2
	s = '1'
	mi = 1
	ma = 1
	for r in range(2, n + 1):
		if i >= 0:
			t1 = arr[i]
		else:
			t1 = n + 1
		if j <= n - 1:
			t2 = arr[j]
		else:
			t2 = n + 1
		temp = min(t1, t2)
		ma = max(ma, temp)
		if temp == t1:
			i = i - 1
		else:
			j = j + 1
		cur[temp - 1] = 1
		if ma == r:
			s += '1'
		else:
			s += '0'
	print(s)


t = int(input())
a = []
for i in range(t):
	n = int(input())
	s = input().split()
	a.append([])
	for j in range(n):
		a[i].append(int(s[j]))
for i in range(t):
	begin = a[i].index(1)
	end = begin
	s = '1'
	l = len(a[i])
	for m in range(2, l):
		while begin > 0 and a[i][begin - 1] <= m:
			begin = begin - 1
		while end < l - 1 and a[i][end + 1] <= m:
			end = end + 1
		if end - begin + 1 == m:
			s = s + '1'
		else:
			s = s + '0'
	if l > 1:
		s = s + '1'
	print(s)


for _ in range(int(input())):
	n = int(input())
	p = list(map(int, input().split()))
	d = dict()
	for i in range(n):
		d[p[i]] = i
	s = '1'
	minm = d[1]
	maxm = d[1]
	for i in range(2, n + 1):
		minm = min(minm, d[i])
		maxm = max(maxm, d[i])
		if maxm - minm == i - 1:
			s += '1'
		else:
			s += '0'
	print(s)


import math
a = int(input())
for i in range(a):
	s = int(input())
	z = list(map(int, input().split()))
	pos = [0 for i in range(len(z) + 1)]
	mini = math.inf
	ans = []
	maxa = 0
	for i in range(len(z)):
		pos[z[i]] = i + 1
	for i in range(len(z)):
		mini = min(pos[i + 1], mini)
		maxa = max(maxa, pos[i + 1])
		if maxa - mini + 1 == i + 1:
			ans.append(1)
		else:
			ans.append(0)
	print(''.join(map(str, ans)))


def perm_check(perm):
	pos = [0 for i in range(len(perm) + 1)]
	for i in range(len(perm)):
		pos[int(perm[i])] = i
	result = []
	max = pos[1]
	min = pos[1]
	for i in range(1, len(perm) + 1):
		if max < pos[i]:
			max = pos[i]
		elif min > pos[i]:
			min = pos[i]
		if max - min + 1 > i:
			result.append('0')
		else:
			result.append('1')
	return ''.join(result)
rounds = int(input())
for i in range(rounds):
	size = input()
	numbers = input().split()
	print(perm_check(numbers))


import sys
from sys import stdin, stdout
import bisect
import math
import heapq

def modinv(n, p):
	return pow(n, p - 2, p)

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())
import math

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l

def main():
	t = inin()
	for _ in range(t):
		n = inin()
		a = ain()
		b = [0] * (n + 1)
		for i in range(n):
			b[a[i]] = i
		j = k = b[1]
		c = [0] * n
		c[0] = 1
		x = 0
		for i in range(2, n + 1):
			while j > b[i]:
				j -= 1
			while k < b[i]:
				k += 1
			x += 1
			if x == k - j:
				c[x] = 1
		print(*c, sep='')
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			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 sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def readnumbers(zero=0):
	conv = ord if py2 else lambda x: x
	A = []
	numb = zero
	sign = 1
	i = 0
	s = sys.stdin.buffer.read()
	try:
		while True:
			if s[i] >= b'0'[0]:
				numb = 10 * numb + conv(s[i]) - 48
			elif s[i] == b'-'[0]:
				sign = -1
			elif s[i] != b'\r'[0]:
				A.append(sign * numb)
				numb = zero
				sign = 1
			i += 1
	except:
		pass
	if s and s[-1] >= b'0'[0]:
		A.append(sign * numb)
	return A
main()


t = int(input())
for i in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	a = [0] * n
	for j in range(n):
		a[lst[j] - 1] = j
	mx = [a[0]]
	mn = [a[0]]
	for j in range(1, n):
		mx.append(max(mx[-1], a[j]))
		mn.append(min(mn[-1], a[j]))
	for m in range(0, n):
		if mx[m] - mn[m] == m:
			print('1', end='')
		else:
			print('0', end='')
	print()


from operator import itemgetter
t = int(input())
res = []
for k in range(0, t):
	n = int(input())
	p = list(map(int, input().split()))
	p = [(p[i], i) for i in range(0, len(p))]
	p.sort(key=itemgetter(0))
	good_numbers = []
	current_max = 0
	current_min = len(p)
	for i in range(0, len(p)):
		el = p[i][1]
		if el > current_max:
			current_max = el
		if el < current_min:
			current_min = el
		if current_max - current_min == i:
			good_numbers.append('1')
		else:
			good_numbers.append('0')
	res.append(good_numbers)
for r in res:
	print(''.join(r))


T = int(input())
for cas in range(T):
	dic = {}
	n = int(input())
	a = list(map(int, input().split()))
	for i in range(n):
		dic[a[i] - 1] = i
	l = n
	r = 0
	for i in range(n):
		l = min(l, dic[i])
		r = max(r, dic[i])
		if r - l == i:
			print(1, end='')
		else:
			print(0, end='')
	print()


def perms(lst):
	pos = [0] * len(lst)
	for i in range(len(lst)):
		pos[int(lst[i]) - 1] = i
	minn = pos[0] + 1
	maxx = pos[0] + 1
	res = ''
	for j in range(len(pos)):
		temp = pos[j] + 1
		if temp < minn:
			minn = temp
		if temp > maxx:
			maxx = temp
		if maxx - minn + 1 == j + 1:
			res += '1'
		else:
			res += '0'
	return res

def main():
	t = int(input())
	while t > 0:
		n = input()
		a = input().split()
		print(perms(a))
		t -= 1
main()


def main():
	test_cases = int(input())
	for test_case in range(test_cases):
		m = int(input())
		arr = [int(x) for x in input().split()]
		result = ['0' for i in range(m)]
		found = set()
		i = 0
		while arr[i] != 1:
			i += 1
		left = i
		right = i
		result[0] = '1'
		looking = 2
		while left > 0 or right < m - 1 or looking <= m:
			if looking in found:
				if right - left + 1 == looking:
					result[looking - 1] = '1'
				looking += 1
				continue
			if left == 0:
				right += 1
				if arr[right] == looking and right - left + 1 == looking:
					result[looking - 1] = '1'
					looking += 1
				found.add(arr[right])
			elif right == m - 1:
				left -= 1
				if arr[left] == looking and right - left + 1 == looking:
					result[looking - 1] = '1'
					looking += 1
				found.add(arr[left])
			elif arr[right + 1] < arr[left - 1]:
				right += 1
				if arr[right] == looking and right - left + 1 == looking:
					result[looking - 1] = '1'
					looking += 1
				found.add(arr[right])
			else:
				left -= 1
				if arr[left] == looking and right - left + 1 == looking:
					result[looking - 1] = '1'
					looking += 1
				found.add(arr[left])
		print(''.join(result))
main()


def main():
	n = int(input())
	p = list(map(int, input().split()))
	index = [0] * n
	ans = [0] * n
	for i in range(n):
		index[p[i] - 1] = i
	(l, r) = ([0] * n, [0] * n)
	(l[0], r[0]) = (index[0], index[0])
	for i in range(1, n):
		l[i] = min(l[i - 1], index[i])
		r[i] = max(r[i - 1], index[i])
	for i in range(n):
		if r[i] - l[i] == i:
			ans[i] = 1
	print(''.join([str(x) for x in ans]))
t = int(input())
for _ in range(t):
	main()


q = int(input())
for _ in range(q):
	n = int(input())
	arr = list(map(int, input().split()))
	pos = [0] * n
	for i in range(n):
		pos[arr[i] - 1] = i
	ans = '1'
	min_v = pos[0]
	max_v = pos[0]
	for m in range(2, n + 1):
		min_v = min(min_v, pos[m - 1])
		max_v = max(max_v, pos[m - 1])
		if max_v - min_v + 1 <= m:
			ans += '1'
		else:
			ans += '0'
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	a = [0] * (n + 1)
	for i in range(n):
		a[p[i]] = i
	res = '1'
	l = a[1]
	r = a[1]
	for i in range(2, n):
		temp = a[i]
		if temp < l:
			l = temp
		if temp > r:
			r = temp
		if r - l < i:
			res = res + '1'
		else:
			res = res + '0'
	if n != 1:
		res = res + '1'
	print(res)


from sys import stdin
for _ in range(int(stdin.readline().rstrip())):
	n = int(input())
	l = list(map(int, stdin.readline().rstrip().split(' ')))
	loc = {}
	for i in range(n):
		loc[l[i]] = i + 1
	m = 0
	mi = 90000000000
	for i in range(1, n + 1):
		a = loc[i]
		if a > m:
			m = a
		if a < mi:
			mi = a
		if i == m - mi + 1:
			print(1, end='')
		else:
			print(0, end='')
	print('')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	arr = []
	for j in range(n):
		b = []
		b.append(a[j])
		b.append(j + 1)
		arr.append(b)
	arr.sort()
	ma = arr[0][1]
	mi = arr[0][1]
	st = ''
	for j in range(n):
		ma = max(ma, arr[j][1])
		mi = min(mi, arr[j][1])
		if ma - mi + 1 == arr[j][0]:
			st += '1'
		else:
			st += '0'
	print(st)


from collections import deque
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = deque(a)
	ans = ''
	curr = n
	lrm = n + 1
	while d:
		if lrm == curr + 1:
			ans += '1'
		else:
			ans += '0'
		if d[-1] == curr:
			lrm = min(d.pop(), lrm)
		elif d[0] == curr:
			lrm = min(d.popleft(), lrm)
		elif d[-1] > d[0]:
			lrm = min(d.pop(), lrm)
		else:
			lrm = min(d.popleft(), lrm)
		curr -= 1
	print(ans[::-1])


import sys, os, io

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

def ri():
	return int(sys.stdin.readline())

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

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools
from collections import deque, defaultdict, OrderedDict
import collections

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	zz = 0
	for _ in range(ri()):
		n = ri()
		a = ria()
		pos = {}
		for i in range(n):
			pos[a[i]] = i
		ans = '1'
		d = 0
		mnx = 0
		mxx = 0
		for i in range(2, n + 1):
			mnx = min(pos[i] - pos[1], mnx)
			mxx = max(pos[i] - pos[1], mxx)
			if mxx - mnx + 1 > i:
				ans += '0'
			else:
				ans += '1'
		ws(ans)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			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, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			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()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

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

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


for i in range(int(input())):
	has = [0] * 200010
	n = int(input())
	ar = list(map(int, input().split()))
	ind = ar.index(1)
	has[1] = 1
	count = 1
	x = ind - 1
	y = ind + 1
	ans = [0] * n
	st = 1
	index = [0] * n
	for i in range(n):
		index[ar[i] - 1] = i
	while count <= n:
		if has[count] == 1 and count == st:
			ans[count - 1] = 1
			count += 1
		else:
			if index[count - 1] >= y:
				while y < n:
					if ar[y] == count:
						has[ar[y]] = 1
						y += 1
						st += 1
						break
					has[ar[y]] = 1
					y += 1
					st += 1
			elif index[count - 1] <= x:
				while x >= 0:
					if ar[x] == count:
						has[ar[x]] = 1
						st += 1
						x -= 1
						break
					has[ar[x]] = 1
					x -= 1
					st += 1
			if has[count] == 1 and count == st:
				ans[count - 1] = 1
			count += 1
	print(''.join(map(str, ans)))


import sys
from math import gcd
from heapq import heappop
from heapq import heappush
from heapq import heapify
from bisect import insort
from bisect import bisect_right
from bisect import bisect_left
from sys import stdin, stdout
from collections import defaultdict, deque
from math import log2, ceil, floor
inp = lambda : int(input())
sip = lambda : input()
mulip = lambda : map(int, input().split())
lst = lambda : list(map(int, input().split()))
slst = lambda : list(sip())
arr2d = lambda x: [[int(j) for j in input().split()] for i in range(x)]
odds = lambda l: len(list(filter(lambda x: x % 2 != 0, l)))
evens = lambda l: len(list(filter(lambda x: x % 2 == 0, l)))
mod = pow(10, 9) + 7
Judge = 0
if Judge:
	sys.stdin = open('input.in', 'r')
for _ in range(inp()):
	n = inp()
	p = lst()
	d = defaultdict(int)
	for i in range(n):
		d[p[i]] = i
	d1 = {}
	l = []
	mn = n + 1
	mx = -1
	for i in range(1, n + 1):
		mn = min(mn, d[i])
		mx = max(mx, d[i])
		if i == 1:
			print(1, end='')
			l.append(d[i])
		elif i == n:
			print(1, end='')
			l.append(d[i])
		else:
			l.append(d[i])
			if mx - mn + 1 == len(l):
				print(1, end='')
			else:
				print(0, end='')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	p = [int(x) for x in input().split()]
	idx = dict()
	for i in range(n):
		idx[p[i]] = i
	ans = [n]
	l = 0
	r = n - 1
	one = idx[1]
	removed = [False for __ in range(n + 1)]
	removed[n] = True
	size = n - 1
	for i in range(n, 1, -1):
		j = idx[i]
		if l <= j <= r:
			if j > one:
				for k in range(r, j - 1, -1):
					remove = p[k]
					if removed[remove] == False:
						removed[remove] = True
						size -= 1
				r = j - 1
			else:
				for k in range(l, j + 1):
					remove = p[k]
					if removed[remove] == False:
						removed[remove] = True
						size -= 1
				l = j + 1
		if size == i - 1:
			ans.append(size)
	ans2 = ['0'] * n
	for x in ans:
		ans2[x - 1] = '1'
	print(''.join(ans2))


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	lst = [-1] * n
	for i in range(n):
		lst[arr[i] - 1] = i
	mini = 1000000000.0
	maxi = -1000000000.0
	ans = ''
	for i in range(n):
		mini = min(mini, lst[i])
		maxi = max(maxi, lst[i])
		ans += '1' if maxi - mini == i else '0'
	print(ans)


import sys

def fun(x):
	return x[0]
t = int(input())
for i in range(t):
	n = int(sys.stdin.readline())
	a = list(map(int, sys.stdin.readline().strip().split()))
	aa = []
	for i in range(n):
		aa.append([a[i], i])
	aa.sort(key=fun)
	mx = aa[0][1]
	mn = aa[0][1]
	op = ['0'] * n
	for j in range(n):
		mx = max(mx, aa[j][1])
		mn = min(mn, aa[j][1])
		if mx - mn == j:
			op[j] = '1'
	print(''.join(op))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	r = [0] * n
	for (i, x) in enumerate(a):
		r[x - 1] = i
	i_min = i_max = r[0]
	ans = []
	for (m, i) in enumerate(r):
		i_min = min(i, i_min)
		i_max = max(i, i_max)
		ans.append(1 if i_max - i_min == m else 0)
	print(*ans, sep='')


def solve():
	n = int(input())
	p = list(map(int, input().split()))
	mp = {p[i]: i + 1 for i in range(n)}
	ans = ''
	mi = 2 * 100000 + 1
	ma = 0
	for i in range(1, n + 1):
		mi = min(mi, mp[i])
		ma = max(ma, mp[i])
		temp = ma - mi + 1
		if temp == i:
			ans += '1'
		else:
			ans += '0'
	print(ans)
t = int(input())
for _ in range(t):
	solve()


import sys, math

def input():
	return sys.stdin.readline()[:-1]

def main():
	q = int(input())
	for _ in range(q):
		n = int(input())
		a = list(map(int, input().split()))
		t = []
		for k in range(n):
			t.append([a[k], k])
		t = sorted(t)
		s = t[0][1]
		(l, r) = (s, s)
		ans = [0 for k in range(n)]
		ans[0] = 1
		for k in range(1, n):
			r = max(r, t[k][1])
			l = min(l, t[k][1])
			if r - l == k:
				ans[k] = 1
		print(*ans, sep='')
main()


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	idx = [0] * (n + 1)
	for i in range(n):
		idx[l[i]] = i
	mnm = idx[1]
	mxm = idx[1]
	ans = '1'
	holeSize = 0
	for m in range(2, n + 1):
		if holeSize == 0:
			if idx[m] == mnm - 1:
				mnm -= 1
				ans += '1'
			elif idx[m] == mxm + 1:
				mxm += 1
				ans += '1'
			else:
				if idx[m] < mnm:
					holeSize += mnm - idx[m] - 1
					mnm = idx[m]
				elif idx[m] > mxm:
					holeSize += idx[m] - mxm - 1
					mxm = idx[m]
				ans += '0'
		elif mnm < idx[m] < mxm:
			holeSize -= 1
			if holeSize == 0:
				ans += '1'
			else:
				ans += '0'
		elif mnm > idx[m]:
			holeSize += mnm - idx[m] - 1
			mnm = idx[m]
			ans += '0'
		else:
			holeSize += idx[m] - mxm - 1
			mxm = idx[m]
			ans += '0'
	print(ans)


import sys
n = int(input())

def isBeautiful(seq, length):
	if set(seq) == set(range(1, length + 1)):
		return True
	else:
		return False

def getAns(k):
	li = [int(x) for x in input().split(' ')]
	liIndices = [0 for x in range(k + 1)]
	for i in range(k):
		liIndices[li[i]] = i
	currMax = liIndices[1]
	currMin = currMax
	currDiff = currMax - currMin
	for m in range(1, k + 1):
		if liIndices[m] > currMax:
			currMax = liIndices[m]
			currDiff = currMax - currMin
		elif liIndices[m] < currMin:
			currMin = liIndices[m]
			currDiff = currMax - currMin
		if currDiff < m:
			sys.stdout.write('1')
		else:
			sys.stdout.write('0')
for i in range(n):
	getAns(int(input()))
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	m = [0 for i in range(n)]
	for i in range(n):
		m[a[i] - 1] = i
	mn = n + 1
	mx = -1
	s = ['0' for i in range(n)]
	for i in range(n):
		mn = min(mn, m[i])
		mx = max(mx, m[i])
		if mx - mn == i:
			s[i] = '1'
	print(''.join(s))


t = int(input())
for i in range(t):
	n = int(input())
	minn = [n + 1] * (n + 1)
	maxx = [0] * (n + 1)
	numbers = [int(x) for x in input().split()]
	for j in range(n):
		minn[numbers[j]] = j + 1
		maxx[numbers[j]] = j + 1
	for j in range(1, n + 1):
		minn[j] = min(minn[j], minn[j - 1])
		maxx[j] = max(maxx[j], maxx[j - 1])
		if maxx[j] - minn[j] + 1 == j:
			print(1, end='')
		else:
			print(0, end='')
	print()


def sum_of_first_n(n):
	return int(n * (n + 1) / 2)
for case in range(int(input())):
	n = int(input())
	index_array = [0] * n
	permutation = [int(x) for x in input().split()]
	for i in range(n):
		index_array[permutation[i] - 1] = i + 1
	answer_string = ['1']
	current_min = 1000000000.0
	current_max = -1
	for i in range(n):
		number = i + 1
		index = index_array[i]
		current_min = min(current_min, index)
		current_max = max(current_max, index)
		if current_max - current_min == number - 1:
			answer_string.append('1')
		else:
			answer_string.append('0')
	answer_string = answer_string[1:]
	print(''.join(answer_string))


n = int(input())
for _ in range(n):
	k = int(input())
	pos = [0] * k
	arr = list(map(int, input().split(' ')))
	for i in range(k):
		pos[arr[i] - 1] = i
	(left, right) = ([0] * k, [0] * k)
	(left[0], right[0]) = (pos[0], pos[0])
	for i in range(1, k):
		left[i] = min(left[i - 1], pos[i])
		right[i] = max(right[i - 1], pos[i])
	for i in range(k):
		if right[i] - left[i] == i:
			print(1, end='')
		else:
			print(0, end='')
	print()


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	ans = ['0'] * n
	ans[0] = '1'
	ans[-1] = '1'
	l = 0
	r = n - 1
	now = n
	while r - l > 1:
		if a[r] > now:
			r -= 1
			continue
		if a[l] > now:
			l += 1
			continue
		if r - l + 1 == now:
			ans[r - l] = '1'
		now -= 1
	if r - l + 1 == now:
		ans[r - l] = '1'
	print(''.join(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 j 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')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7
for _ in range(INT()):
	N = INT()
	A = [a - 1 for a in LIST()]
	atoi = {}
	for (i, a) in enumerate(A):
		atoi[a] = i
	l = INF
	r = 0
	ans = []
	for a in range(N):
		i = atoi[a]
		l = min(l, i)
		r = max(r, i)
		seg = r - l
		if seg == a:
			ans.append('1')
		else:
			ans.append('0')
	print(''.join(ans))


t = int(input())
for _ in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	head = 0
	tail = n - 1
	ans = [0] * n
	ans[0] = 1
	maximum = n
	next_maximum = n - 1
	for i in range(n - 1, -1, -1):
		if i + 1 == maximum:
			ans[i] = 1
		if p[head] > p[tail]:
			if p[head] == maximum:
				maximum = next_maximum
				next_maximum -= 1
			elif p[head] - 1 < next_maximum:
				next_maximum = p[head] - 1
			if p[head] < maximum:
				maximum = next_maximum
				next_maximum -= 1
			head += 1
		else:
			if p[tail] == maximum:
				maximum = next_maximum
				next_maximum -= 1
			elif p[tail] - 1 < next_maximum:
				next_maximum = p[tail] - 1
			if p[tail] < maximum:
				maximum = next_maximum
				next_maximum -= 1
			tail -= 1
	print(*ans, sep='')


from collections import defaultdict
t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	pair = defaultdict(int)
	for j in range(n):
		pair[l[j]] = j
	minindex = pair[1]
	maxindex = pair[1]
	output = '1'
	for j in range(2, n + 1):
		index = pair[j]
		if index < minindex:
			minindex = index
		if index > maxindex:
			maxindex = index
		if maxindex - minindex < j:
			output += '1'
		else:
			output += '0'
	print(output)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	an = ['0'] * n
	an[0] = an[n - 1] = '1'
	x = [0] * n
	for i in range(n):
		x[l[i] - 1] = i + 1
	f = 0
	c = 0
	m = ma = x[0]
	for i in range(1, n - 1):
		if f == 0 and (m - x[i] == 1 or x[i] - ma == 1):
			an[i] = '1'
			m = min(m, x[i])
			ma = max(ma, x[i])
		elif x[i] > m and x[i] < ma:
			c -= 1
			if c == 0:
				f = 0
				an[i] = '1'
		else:
			f = 1
			c += x[i] - ma - 1 if x[i] > ma else m - x[i] - 1
			m = min(m, x[i])
			ma = max(ma, x[i])
	print(''.join(an))


def move():
	global mex
	while vis[mex]:
		mex += 1
t = int(input())
mex = 1
while t:
	mex = 1
	t -= 1
	n = int(input())
	vis = [0 for i in range(n + 20)]
	ans = [0 for i in range(n + 20)]
	l = [int(i) for i in input().split()]
	l.insert(0, n + 1)
	l.append(n + 1)
	id = 0
	for j in range(len(l)):
		if l[j] == 1:
			id = j
	lef = id
	rt = id
	ans[1] = 1
	vis[1] = 1
	while lef != 0 and rt != len(l) - 1:
		if mex - 1 == rt - lef + 1:
			ans[mex - 1] = 1
		if l[lef - 1] < l[rt + 1]:
			vis[l[lef - 1]] = 1
			lef -= 1
			move()
		else:
			vis[l[rt + 1]] = 1
			rt += 1
			move()
	for i in range(1, n + 1):
		print(ans[i], end='')
	print()


def main():

	def solve():
		n = int(input())
		pp = [int(p) for p in input().split()]
		op = pp.index(1)
		b1 = list(reversed(pp[:op])) + [n + 1]
		a1 = pp[op:] + [n + 1]
		bp = 0
		ap = 0
		qq = []
		while len(qq) < n:
			if b1[bp] < a1[ap]:
				qq.append(b1[bp])
				bp += 1
			else:
				qq.append(a1[ap])
				ap += 1
		mm = [1]
		for q in qq[1:]:
			if q > mm[-1]:
				mm.append(q)
			else:
				mm.append(mm[-1])
		res = []
		for (i, m) in enumerate(mm):
			if i + 1 >= m:
				res.append('1')
			else:
				res.append('0')
		print(''.join(res))
	q = int(input())
	for _ in range(q):
		solve()
main()


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	pos = [0] * (n + 1)
	for (i, x) in enumerate(a):
		pos[x] = i
	used = [0, 1] + [0] * n
	ans = [0] * n
	(l, r) = (pos[1], pos[1])
	count = 1
	for x in range(1, n + 1):
		if not used[x]:
			if pos[x] < l:
				while not used[x]:
					l -= 1
					used[a[l]] = 1
					count += 1
			else:
				while not used[x]:
					r += 1
					used[a[r]] = 1
					count += 1
		if count == x:
			ans[x - 1] = 1
	print(*ans, sep='')


t = int(input())
while t:
	n = int(input())
	arr = [int(x) for x in input().split()]
	ans = ''
	p = [0] * n
	for i in range(n):
		p[arr[i] - 1] = i
	l = n + 1
	r = -1
	for i in range(n):
		l = min(l, p[i])
		r = max(r, p[i])
		if r - l == i:
			ans += '1'
		else:
			ans += '0'
	print(ans)
	t -= 1


for _ in range(int(input())):
	n = int(input())
	aff = 0
	positions = {}
	(l, r) = (n, 0)
	for i in input().split():
		positions[int(i) - 1] = aff
		aff += 1
	for i in range(n):
		l = min(l, positions[i])
		r = max(r, positions[i])
		if r - l == i:
			print('1', sep='', end='')
		else:
			print('0', sep='', end='')
	print(end='\n')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	pos = [0 for i in range(n + 1)]
	for i in range(n):
		pos[a[i]] = i
	ans = [-1 for i in range(n)]
	ans[0] = 1
	(l, r) = (pos[1], pos[1])
	for i in range(2, n + 1):
		l = min(l, pos[i])
		r = max(r, pos[i])
		if r - l == i - 1:
			ans[i - 1] = 1
		else:
			ans[i - 1] = 0
	print(''.join(map(str, ans)))


import sys
readline = sys.stdin.readline
mr = lambda : map(int, readline().split())
t = int(readline())
Ans = []
for _ in range(t):
	n = int(readline())
	tmpArr = list(mr())
	tmpArr2 = [0] * n
	for i in range(n):
		tmpArr2[tmpArr[i] - 1] = i
	(_max, _min) = (tmpArr2[0], tmpArr2[0])
	tmpArr[0] = 0 if _max - _min else 1
	for i in range(1, n):
		_min = min(_min, tmpArr2[i])
		_max = max(_max, tmpArr2[i])
		tmpArr[i] = 1 if _max - _min == i else 0
	Ans.append(''.join(map(str, tmpArr)))
print('\n'.join(map(str, Ans)))


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	l = r = arr.index(1)
	print(1, end='')
	last = arr[l]
	missed = 0
	l -= 1
	r += 1
	while l >= 0 and r < n:
		if arr[l] < arr[r]:
			if arr[l] - last - 1 >= 0:
				missed += arr[l] - last - 1
			else:
				missed -= 1
			print('0' if missed else '1', end='')
			if arr[l] > last:
				last = arr[l]
			l -= 1
		else:
			if arr[r] - last - 1 >= 0:
				missed += arr[r] - last - 1
			else:
				missed -= 1
			print('0' if missed else '1', end='')
			if arr[r] > last:
				last = arr[r]
			r += 1
	while l >= 0:
		if arr[l] - last - 1 >= 0:
			missed += arr[l] - last - 1
		else:
			missed -= 1
		print('0' if missed else '1', end='')
		if arr[l] > last:
			last = arr[l]
		l -= 1
	while r < n:
		if arr[r] - last - 1 >= 0:
			missed += arr[r] - last - 1
		else:
			missed -= 1
		print('0' if missed else '1', end='')
		if arr[r] > last:
			last = arr[r]
		r += 1
	print()


def run():
	input()
	l = map(int, input().split(' '))
	l1 = sorted(enumerate(l, 1), key=lambda x: x[1])
	max_ = l1[0][0]
	min_ = max_
	diff = 0
	result = {'1': 1}
	for element in l1[1:]:
		if element[0] > max_:
			diff += element[0] - max_ - 1
			max_ = element[0]
		elif element[0] < min_:
			diff += min_ - element[0] - 1
			min_ = element[0]
		else:
			diff -= 1
		result[element] = 0 if diff else 1
	print(*result.values(), sep='')
for _ in range(int(input())):
	run()


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	dic = {a[i]: i for i in range(len(a))}
	if n == 1:
		print('1')
		continue
	else:
		minnind = dic[1]
		maxxind = dic[1]
		print('1', end='')
		for i in range(2, n + 1):
			if maxxind < dic[i]:
				maxxind = dic[i]
			if minnind > dic[i]:
				minnind = dic[i]
			if abs(maxxind - minnind) == i - 1:
				print('1', end='')
			else:
				print('0', end='')
		print()


r = int(input())
W = []
for u in range(r):
	n = int(input())
	P = list(map(int, input().split()))
	A = []
	for i in range(len(P)):
		A.append([P[i], i])
	A.sort(key=lambda elem: elem[0])
	C = [0] * len(A)
	V = [0] * len(A)
	C[A[0][1]] = 1
	V[A[0][0] - 1] = 1
	d = 0
	D = [A[0][1], A[0][1]]
	for i in range(1, len(A)):
		t = A[i][1]
		C[t] = 1
		flag = 0
		v = D[1] - D[0]
		if D[0] < t < D[1]:
			flag += 1
		if t > D[1]:
			D = [D[0], t]
		if t < D[0]:
			D = [t, D[1]]
		v1 = D[1] - D[0]
		if i == len(A) - 1:
			V[A[i][0] - 1] = 1
			continue
		if d == 0:
			if t - 1 > -1 and C[t - 1] == 1:
				V[A[i][0] - 1] = 1
			elif t + 1 < len(C) and C[t + 1] == 1:
				V[A[i][0] - 1] = 1
			else:
				V[A[i][0] - 1] = 0
				d += v1 - v - 1
		elif d == 1:
			if flag == 1:
				V[A[i][0] - 1] = 1
				d -= 1
			else:
				V[A[i][0] - 1] = 0
				d += v1 - v - 1
		else:
			V[A[i][0] - 1] = 0
			if v1 == v:
				d -= 1
			else:
				d += v1 - v - 1
	W.append(V)
for i in range(len(W)):
	for j in range(len(W[i])):
		print(W[i][j], end='')
	print()


for j in range(int(input())):
	n = int(input())
	c = list(map(int, input().split()))
	index = [0] * n
	for i in range(n):
		index[c[i] - 1] = i
	ma = 0
	mi = n
	ans = ['0'] * n
	for k in range(n):
		ma = max(index[k], ma)
		mi = min(index[k], mi)
		if ma - mi <= k:
			ans[k] = '1'
	print(''.join(ans))


def solve():
	n = int(input())
	p = list(map(int, input().split()))
	l = 0
	r = len(p) - 1
	locations = dict()
	for (i, e) in enumerate(p):
		locations[e] = i
	one = locations[1]
	discarded = set()
	mxp = n
	found = ['0'] * n
	for curr in reversed(range(1, n + 1)):
		if curr in discarded:
			continue
		splt = locations[curr]
		if curr <= mxp:
			found[curr - 1] = '1'
		if splt < one:
			for i in range(l, splt):
				discarded.add(p[i])
				mxp = min(mxp, p[i])
			l = splt
		else:
			for i in range(splt + 1, r + 1):
				discarded.add(p[i])
				mxp = min(mxp, p[i])
			r = splt
	print(''.join(found))
for _ in range(int(input())):
	solve()


def nextchr(c):
	return chr((ord(c) % 97 + 1) % 3 + 97)
t = int(input())
for you in range(t):
	n = int(input())
	l = input().split()
	li = [int(i) for i in l]
	arr = [0 for i in range(n)]
	for i in range(n):
		arr[li[i] - 1] = i
	currmax = arr[0]
	currmin = arr[0]
	lo = [0 for i in range(n)]
	for i in range(n):
		currmax = max(currmax, arr[i])
		currmin = min(currmin, arr[i])
		if currmax - currmin + 1 == i + 1:
			lo[i] = 1
	for i in range(n):
		print(lo[i], end='')
	print()


t = int(input())
for i in range(t):
	r = int(input())
	l = list(map(int, input().split()))
	l2 = [i for i in range(1, r + 1)]
	for i in range(r):
		a = l[i]
		l2[a - 1] = i + 1
	ans = [1]
	p = 0
	q = 0
	ma = l2[0]
	mi = l2[0]
	for j in range(1, r):
		if l2[j] > ma:
			ma = l2[j]
		if l2[j] < mi:
			mi = l2[j]
		u = ma - mi
		if u == j:
			ans.append(1)
		else:
			ans.append(0)
	print(*ans, sep='')


t = int(input())
while t > 0:
	n = int(input())
	s = list(map(int, input().split()))
	for i in range(len(s)):
		if s[i] == 1:
			break
	j = i
	c = 1
	max_seen = 1
	ans = ['1']
	while j > 0 and i < len(s) - 1:
		if s[j - 1] < s[i + 1]:
			j -= 1
			max_seen = max(max_seen, s[j])
		else:
			i += 1
			max_seen = max(max_seen, s[i])
		c += 1
		if max_seen == c:
			ans.append('1')
		else:
			ans.append('0')
	while i < len(s) - 1:
		i += 1
		max_seen = max(max_seen, s[i])
		c += 1
		if max_seen == c:
			ans.append('1')
		else:
			ans.append('0')
	while j > 0:
		j -= 1
		max_seen = max(max_seen, s[j])
		c += 1
		if max_seen == c:
			ans.append('1')
		else:
			ans.append('0')
	print(''.join(ans))
	t -= 1


t = int(input())
for _ in range(t):
	N = int(input())
	P = list(map(int, input().split()))
	pos = [0] * N
	for i in range(N):
		pos[P[i] - 1] = i
	pos_max = -1
	pos_min = float('inf')
	ans = [0] * N
	for i in range(0, N):
		pos_max = max(pos_max, pos[i])
		pos_min = min(pos_min, pos[i])
		if pos_max - pos_min + 1 == i + 1:
			ans[i] = 1
	print(*ans, sep='')


import sys

def main():
	for tc in range(int(input())):
		n = int(input())
		arr = get_array()
		d = {}
		for i in range(n):
			d[arr[i]] = i
		mn = n + 1
		mx = 0
		ans = ''
		for i in range(1, n + 1):
			mn = min(mn, d[i])
			mx = max(mx, d[i])
			if mx - mn + 1 == i:
				ans += '1'
			else:
				ans += '0'
		print(*ans, sep='')
get_array = lambda : list(map(int, sys.stdin.readline().split()))
get_ints = lambda : map(int, sys.stdin.readline().split())
input = lambda : sys.stdin.readline().strip()
main()


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	res = ['1'] * len(l)
	index = l.index(1)
	i1 = index - 1
	i2 = index + 1
	curr = 2
	start = curr
	while i1 >= 0 or i2 <= len(l) - 1:
		a1 = 10 ** 10
		a2 = 10 ** 10
		a = None
		if i1 >= 0:
			a1 = l[i1]
		if i2 <= len(l) - 1:
			a2 = l[i2]
		if a1 < a2:
			a = a1
			i1 -= 1
		else:
			a = a2
			i2 += 1
		for j in range(max(start, curr), a):
			res[j - 1] = '0'
			start = j
		curr += 1
	print(''.join(res))


for _ in range(int(input())):
	a = int(input())
	li = list(map(int, input().split()))
	p = 1
	ans = ['1']
	l = li.index(1)
	r = l
	su = 1
	for i in range(2, a + 1):
		p += i
		if l == 0:
			su += li[r + 1]
			r += 1
		elif r == a - 1:
			su += li[l - 1]
			l -= 1
		elif li[l - 1] < li[r + 1]:
			su += li[l - 1]
			l -= 1
		else:
			su += li[r + 1]
			r += 1
		if p == su:
			ans.append('1')
		else:
			ans.append('0')
	print(''.join(ans))


from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time

def I():
	return int(input())

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

def LI():
	return [int(i) for i in input().split()]

def LI_():
	return [int(i) - 1 for i in input().split()]

def StoI():
	return [ord(i) - 97 for i in input()]

def ItoS(nn):
	return chr(nn + 97)

def GI(V, E, Directed=False, index=0):
	org_inp = []
	g = [[] for i in range(n)]
	for i in range(E):
		inp = LI()
		org_inp.append(inp)
		if index == 0:
			inp[0] -= 1
			inp[1] -= 1
		if len(inp) == 2:
			(a, b) = inp
			g[a].append(b)
			if not Directed:
				g[b].append(a)
		elif len(inp) == 3:
			(a, b, c) = inp
			aa = (inp[0], inp[2])
			bb = (inp[1], inp[2])
			g[a].append(bb)
			if not Directed:
				g[b].append(aa)
	return (g, org_inp)

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
YN = ['Yes', 'No']
mo = 10 ** 9 + 7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
input = lambda : sys.stdin.readline().rstrip()

def ran_input():
	import random
	n = random.randint(4, 16)
	a = sorted([-1 * random.randint(1, 5) for _ in range(n)])[::-1]
	return (n, a)
show_flg = False
show_flg = True

def inp():
	n = I()
	p = LI()
	return (n, p)
t = I()
for _ in range(t):
	(n, p) = inp()
	ans = 0
	m = [0] * n
	for i in range(n):
		m[p[i] - 1] = i
	(mx, mn) = (m[0], m[0])
	ans = []
	for i in range(n):
		mx = max(mx, m[i])
		mn = min(mn, m[i])
		if mx - mn == i:
			ans += ['1']
		else:
			ans += ['0']
	print(''.join(ans))


import sys
import collections
import heapq
import math
input = sys.stdin.readline

def rints():
	return map(int, input().strip().split())

def rstr():
	return input().strip()

def rint():
	return int(input().strip())

def rintas():
	return [int(i) for i in input().strip().split()]

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
t = rint()
for _ in range(t):
	n = rint()
	p = [(v, i + 1) for (i, v) in enumerate(rintas())]
	p.sort()
	ans = ['0'] * n
	ans[0] = '1'
	ans[n - 1] = '1'
	low = p[0][1]
	high = p[0][1]
	cur = 1
	for i in range(1, n - 1):
		low = min(low, p[i][1])
		high = max(high, p[i][1])
		cur += 1
		if high - low + 1 == cur:
			ans[i] = '1'
	print(''.join(ans))


tests = int(input())
for te in range(tests):
	n = int(input())
	per = list(map(int, input().split()))
	for i in range(n):
		per[i] -= 1
	arr = [0 for i in range(n)]
	ans = [0 for i in range(n)]
	for i in range(n):
		arr[per[i]] = i
	mina = n
	maxa = -1
	stringa = ''
	for i in range(n):
		mina = min(mina, arr[i])
		maxa = max(maxa, arr[i])
		if maxa - mina == i:
			ans[i] = 1
		else:
			continue
	for i in range(n):
		if i == n - 1:
			print(str(ans[i]))
			break
		print(str(ans[i]), end='')


import sys
input = sys.stdin.readline
Q = int(input())
Query = []
for _ in range(Q):
	N = int(input())
	A = list(map(int, input().split()))
	Query.append((N, A))
for (N, A) in Query:
	dic = {}
	for (i, a) in enumerate(A):
		dic[a] = i
	l = N + 1
	r = -1
	ans = ''
	for n in range(1, N + 1):
		i = dic[n]
		l = min(l, i)
		r = max(r, i)
		if r - l + 1 == n:
			ans += '1'
		else:
			ans += '0'
	print(ans)


for i in range(int(input())):
	n = int(input())
	a = [0] + list(map(int, input().split())) + [0]
	p = [a[i] for i in range(n + 2)]
	d = {}
	for k in range(1, n + 1):
		d[a[k]] = k
	l = 10 ** 12
	r = -1
	for i in range(1, n + 1):
		l = min(l, d[i])
		r = max(r, d[i])
		if r - l + 1 == i:
			print(1, end='')
		else:
			print(0, end='')
	print()


t = int(input())
for o in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	pos = [0] * n
	for i in range(n):
		pos[a[i] - 1] = i
	m1 = pos[0]
	m2 = pos[0]
	ans = []
	for i in range(n):
		if pos[i] > m2:
			m2 = pos[i]
		if pos[i] < m1:
			m1 = pos[i]
		if m2 - m1 == i:
			ans.append(1)
		else:
			ans.append(0)
	print(*ans, sep='')


t = int(input())
while t:
	n = int(input())
	l = list(map(int, input().split()))
	l1 = [0] * (n + 1)
	din = {}
	for i in range(n):
		din[l[i]] = i
	cnt = 1
	j = 1
	ans = [0] * (n + 1)
	ans[1] = 1
	ans[n] = 1
	count = 0
	l_m = din[1]
	r_m = din[1]
	j = 2
	while j <= n:
		ri = din[j]
		ch = 0
		if l_m <= ri and r_m >= ri:
			l1[j] = 0
			count -= 1
			if count == 0:
				ans[j] = 1
		else:
			if ri < l_m:
				for i in range(l_m - 1, ri - 1, -1):
					if l[i] > j:
						l1[i] = 1
						count += 1
						ch = 1
			else:
				for i in range(r_m, ri + 1):
					if l[i] > j:
						l1[i] = 1
						count += 1
						ch = 1
			if ch == 0 and count == 0:
				ans[j] = 1
		if ri < min(l_m, r_m):
			l_m = ri
		if ri > max(l_m, r_m):
			r_m = ri
		j += 1
	for i in range(1, n + 1):
		print(ans[i], end='')
	print()
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	mas = list(map(int, input().split()))
	ans = []
	for j in range(n):
		ans.append([mas[j], j])
	ans.sort()
	dop = [1]
	mini = ans[0][1]
	maxi = ans[0][1]
	for j in range(2, n + 1):
		mini = min(mini, ans[j - 1][1])
		maxi = max(maxi, ans[j - 1][1])
		if maxi - mini == j - 1:
			dop.append(1)
		else:
			dop.append(0)
	for j in dop:
		print(j, end='')
	print()


import sys
for _ in range(int(sys.stdin.readline().lstrip().rstrip())):
	n = int(sys.stdin.readline().lstrip().rstrip())
	arr = list(map(int, sys.stdin.readline().lstrip().rstrip().split()))
	ind = arr.index(1)
	m = 1
	ans = '1'
	(l, r) = (ind, ind)
	for i in range(2, n + 1):
		(x, y) = (10 ** 10, 10 ** 10)
		if r + 1 < n:
			x = arr[r + 1]
		if l - 1 >= 0:
			y = arr[l - 1]
		minn = min(x, y)
		m = max(minn, m)
		if m == i:
			ans += '1'
		else:
			ans += '0'
		if x == minn:
			r += 1
		else:
			l -= 1
	sys.stdout.write(ans + '\n')


for _ in range(int(input())):
	n = int(input())
	p = list(map(int, input().split()))
	inv = [0] * (n + 1)
	for i in range(n):
		inv[p[i]] = i
	out = ''
	(mx, mn) = (0, n)
	for i in range(1, n + 1):
		(mx, mn) = (max(inv[i], mx), min(inv[i], mn))
		out += '1' if mx - mn + 1 == i else '0'
	print(out)


t = int(input())
for i in range(t):
	n = int(input())
	line = input().split()
	pos = [0] * n
	index = 0
	for char_num in line:
		num = int(char_num)
		pos[num - 1] = index
		index += 1
	most_left = n + 1
	most_rigth = -1
	for m in range(n):
		if pos[m] > most_rigth:
			most_rigth = pos[m]
		if pos[m] < most_left:
			most_left = pos[m]
		distance = most_rigth - most_left
		if distance == m:
			print('1', end='')
		else:
			print('0', end='')
	print()


for _ in range(int(input())):
	n = int(input())
	b = [0] * n
	st = set()
	a = [int(i) for i in input().split()]
	for i in range(len(a)):
		b[a[i] - 1] = i
	(mini, maxi) = (b[0], b[0])
	ans = []
	for i in b:
		st.add(i)
		if i < mini:
			mini = i
		if i > maxi:
			maxi = i
		if len(st) == maxi - mini + 1:
			ans.append(1)
		else:
			ans.append(0)
	for i in ans:
		print(i, end='')
	print()


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = ['0'] * n
	ans[0] = '1'
	ans[-1] = '1'
	dic = {}
	for i in range(n):
		dic[arr[i]] = i
	start = dic[1]
	end = dic[1]
	for i in range(2, n):
		pos = dic[i]
		if pos < start:
			start = pos
		elif pos > end:
			end = pos
		if end - start + 1 == i:
			ans[i - 1] = '1'
	print(''.join(ans))


from sys import stdin
from bisect import bisect_left
test_cases = True
if test_cases:
	t = int(stdin.readline())
	while t:
		n = int(input())
		a = list(map(int, stdin.readline().split()))
		dd = dict()
		dd[1] = 1
		dd[n] = 1
		p = dict()
		for i in range(n):
			p[a[i]] = i
		(l, r) = (p[1], p[1])
		for i in range(2, n):
			c = p[i]
			if c < l:
				l = c
			if c > r:
				r = c
			if abs(r - l) + 1 == i:
				dd[i] = 1
			else:
				dd[i] = 0
		for i in range(1, n + 1):
			print(dd[i], end='')
		print()
		t -= 1
else:
	(k, n) = map(int, stdin.readline().split())


q = int(input())
for i in range(q):
	n = int(input())
	p = list(map(int, input().split(' ')))
	idx = [0] * (n + 1)
	for i in range(n):
		idx[p[i]] = i
	bty = [0] * (n + 1)
	bty[1] = 1
	bty[n] = 1
	st = idx[1]
	ed = idx[1]
	for i in range(2, n):
		if idx[i] > ed:
			ed = idx[i]
		elif idx[i] < st:
			st = idx[i]
		if i == ed - st + 1:
			bty[i] = 1
	out = ''
	for i in range(1, n + 1):
		out = out + str(bty[i])
	print(out)


for _ in range(int(input())):
	n = int(input())
	p = list(map(int, input().split()))
	pos = [0 for i in range(n)]
	for i in range(n):
		pos[p[i] - 1] = i
	ans = ['0' for i in range(n)]
	mi = float('inf')
	ma = 0
	for i in range(n):
		ma = max(ma, pos[i])
		mi = min(mi, pos[i])
		if ma - mi == i:
			ans[i] = '1'
	print(''.join(ans))


t = int(input())
for _ in range(t):
	n = int(input())
	s = [int(x) for x in input().split()]
	pos = [0] * (n + 1)
	ptr1 = 0
	ptr2 = 0
	for i in range(0, len(s)):
		pos[s[i]] = i
		if s[i] == 1:
			ptr1 = i
			ptr2 = i
	mx = 1
	ans = []
	for i in range(1, n + 1):
		if pos[i] <= ptr2 and pos[i] >= ptr1:
			mx = mx
		elif pos[i] > ptr2:
			for j in range(ptr2, pos[i] + 1):
				mx = max(mx, s[j])
			ptr2 = pos[i]
		elif pos[i] < ptr1:
			for j in range(ptr1, pos[i] - 1, -1):
				mx = max(mx, s[j])
			ptr1 = pos[i]
		if mx == i and ptr2 - ptr1 + 1 == mx:
			ans.append('1')
		else:
			ans.append('0')
	ans = ''.join(ans)
	print(ans)


n = int(input())
for i in range(n):
	k = int(input())
	m = list(map(int, input().split()))
	pos = [0] * k
	for i in range(k):
		pos[m[i] - 1] = i + 1
	minpos = k
	maxpos = 1
	s = ''
	for i in range(k):
		if pos[i] < minpos:
			minpos = pos[i]
		if pos[i] > maxpos:
			maxpos = pos[i]
		if maxpos - minpos == i:
			print(1, end='')
		else:
			print(0, end='')
	print()


import sys
tests = int(sys.stdin.readline())
for _ in range(tests):
	n = int(sys.stdin.readline())
	arr = list(map(int, sys.stdin.readline().split()))
	sorted_arr = sorted([(el, i) for (i, el) in enumerate(arr)])
	min_so_far = sorted_arr[0][1]
	max_so_far = sorted_arr[0][1]
	print('1', end='')
	for i in range(1, n):
		min_so_far = min(min_so_far, sorted_arr[i][1])
		max_so_far = max(max_so_far, sorted_arr[i][1])
		print('1' if abs(min_so_far - max_so_far) <= i else '0', end='')
	print()


def solve(xs):
	indices = dict()
	for (i, x) in enumerate(xs):
		indices[x] = i
	l = r = indices[1]
	size = len(xs)
	beautiful = [False for _ in range(size)]
	beautiful[0] = True
	i = 2
	while i <= size:
		ind = indices[i]
		if ind < l:
			l = ind
		if ind > r:
			r = ind
		if r - l + 1 == i:
			beautiful[i - 1] = True
		i += 1
	return beautiful
for _ in range(int(input())):
	input()
	xs = [int(x) for x in input().split()]
	ans = solve(xs)
	print(''.join(('1' if b else '0' for b in ans)))


inputs = []
for _ in range(int(input())):
	input()
	inputs.append(list(map(int, input().split())))
for thing in inputs:
	stuff = set([1])
	result = [False] * len(thing)
	if len(thing) == 1:
		print('1')
		continue
	elif len(thing) == 0:
		print('')
		continue
	_max = 1
	lpos = thing.index(1)
	rpos = lpos
	result[0] = True
	while lpos > 0 or rpos < len(thing) - 1:
		if lpos > 0 and rpos < len(thing) - 1:
			if thing[lpos - 1] < thing[rpos + 1]:
				lpos -= 1
				stuff.add(thing[lpos])
				_max = max(thing[lpos], _max)
			else:
				rpos += 1
				stuff.add(thing[rpos])
				_max = max(thing[rpos], _max)
		elif lpos > 0:
			lpos -= 1
			stuff.add(thing[lpos])
			_max = max(thing[lpos], _max)
		elif rpos < len(thing) - 1:
			rpos += 1
			stuff.add(thing[rpos])
			_max = max(thing[rpos], _max)
		if _max == len(stuff):
			result[_max - 1] = True
	print(''.join(('1' if i else '0' for i in result)))


t = int(input())
for _ in range(0, t):
	n = int(input())
	ind = [0] * (n + 2)
	lst = [int(i) for i in input().split()]
	for i in range(1, n + 1):
		ind[lst[i - 1]] = i
	s = ['1']
	minn = maxx = ind[1]
	for m in range(2, n + 1):
		maxx = max(maxx, ind[m])
		minn = min(minn, ind[m])
		if maxx - minn == m - 1:
			s.append('1')
		else:
			s.append('0')
	print(''.join(s))


for i in range(int(input())):
	n = int(input())
	p = list(map(int, input().split()))
	position = {}
	for i in range(n):
		position[p[i]] = i + 1
	(l, r) = (position[1], position[1])
	answear = '1'
	for i in range(2, n + 1):
		num = position[i]
		if num > r:
			r = num
		elif num < l:
			l = num
		if r - l + 1 == i:
			answear += '1'
		else:
			answear += '0'
	print(answear)


t = int(input())
for _ in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	d = {p[i]: i for i in range(n)}
	min_i = d[1]
	max_i = d[1]
	print('1', end='')
	for i in range(2, n + 1):
		min_i = min(min_i, d[i])
		max_i = max(max_i, d[i])
		if max_i - min_i == i - 1:
			print('1', end='')
		else:
			print('0', end='')
	print()


import array
nmax = 2 * 10 ** 5 + 1
n = int(input())
ans = [0 for _ in range(nmax)]
pos = [0 for _ in range(nmax)]
while n > 0:
	q = int(input())
	for (pi, _i) in enumerate(input().split()):
		i = int(_i)
		pos[i] = pi + 1
		ans[i] = 0
	lf = q + 1
	rg = 0
	for i in range(1, q + 1, 1):
		lf = min(lf, pos[i])
		rg = max(rg, pos[i])
		if rg - lf + 1 == i:
			ans[i] = 1
	n -= 1
	print(*ans[1:q + 1], sep='')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	d = [-1] * (n + 1)
	for i in range(n):
		d[l[i]] = i
	r = [''] * (n + 1)
	m = 0
	mi = 10 ** 6
	for i in range(1, n + 1):
		m = max(m, d[i])
		mi = min(mi, d[i])
		if m - mi == i - 1:
			r[i] = '1'
		else:
			r[i] = '0'
	print(''.join(r))


for _ in range(int(input())):
	_ = input()
	tmp = input()
	n = map(int, tmp.split())
	n = list(n)
	for (i, x) in enumerate(n):
		if x == 1:
			break
	a = b = i + 1
	MAX = 1
	ans = [1]
	n = [float('inf')] + list(n) + [float('inf')]
	for i in range(2, len(n) - 1):
		if n[a - 1] > n[b + 1]:
			MAX = max(n[b + 1], MAX)
			b += 1
		else:
			MAX = max(n[a - 1], MAX)
			a -= 1
		if MAX == i:
			ans.append(1)
		else:
			ans.append(0)
	for (i, x) in enumerate(ans):
		ans[i] = str(x)
	print(''.join(ans))


x = int(input())
B = []
for j in range(x):
	a = int(input())
	A = list(map(int, input().split()))
	for i in range(a):
		A[i] = [A[i], i]
	A.sort()
	Min = A[0][1]
	Max = A[0][1]
	s = '1'
	for i in range(1, a):
		if A[i][1] > Max:
			Max = A[i][1]
		elif A[i][1] < Min:
			Min = A[i][1]
		if Max - Min > i:
			s += '0'
		else:
			s += '1'
	B.append(s)
for a in B:
	print(a)


def f(L):
	n = len(L)
	M = [0] * (len(L) + 1)
	for i in range(len(L)):
		M[L[i]] = i
	s = [0] * len(L)
	s[0] = 1
	sumof = M[1]
	mx = M[1]
	mi = M[1]
	for i in range(2, n):
		k = M[i]
		if k > mx:
			mx = k
		if k < mi:
			mi = k
		sumof += k
		if sumof == mx * (mx + 1) // 2 - (mi - 1) * mi // 2:
			s[i - 1] = 1
	s[n - 1] = 1
	return s
for i in ' ' * int(input()):
	n = int(input())
	s = f(list(map(int, input().split())))
	for i in s:
		print(i, end='')
	print()


t = int(input())
for idx in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	pos_p = [0 for i in range(n)]
	for i in range(n):
		pos_p[p[i] - 1] = i
	pmin = pos_p[0]
	pmax = pos_p[0]
	s = ''
	for i in range(n):
		if pos_p[i] < pmin:
			pmin = pos_p[i]
		if pos_p[i] > pmax:
			pmax = pos_p[i]
		if pmax - pmin != i:
			s += '0'
		else:
			s += '1'
	print(s)


T = int(input())
for t in range(T):
	N = int(input())
	p = list(map(int, input().split()))
	l = p.index(1)
	r = l
	max_encountered = 1
	s = ['0' for i in range(N + 1)]
	s[1] = '1'
	for i in range(2, N + 1):
		if l != 0 and r != N - 1:
			if p[l - 1] < p[r + 1]:
				new = p[l - 1]
				l -= 1
			else:
				new = p[r + 1]
				r += 1
		elif l == 0:
			new = p[r + 1]
			r += 1
		elif r == N - 1:
			new = p[l - 1]
			l -= 1
		max_encountered = max(new, max_encountered)
		if max_encountered == i:
			s[i] = '1'
	print(''.join(s[1:]))


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l1 = [0] * n
	for x in range(n):
		l1[l[x] - 1] = x
	high = -1
	low = n + 1
	for x in range(n):
		high = max(high, l1[x])
		low = min(low, l1[x])
		if high - low == x:
			print('1', end='')
		else:
			print('0', end='')
	print()


import sys

def I():
	return sys.stdin.readline().rstrip()
for _ in range(int(I())):
	n = int(I())
	l = list(map(int, I().split()))
	r = list(range(n))
	r.sort(key=lambda x: l[x])
	(mn, mx) = (None, None)
	for i in range(n):
		if mn is None:
			mn = mx = r[i]
		else:
			mn = min(mn, r[i])
			mx = max(mx, r[i])
		l[i] = '1' if mx - mn == i else '0'
	print(''.join(l))


import sys

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

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

def oint():
	return int(input())
t = oint()
for _ in range(t):
	n = oint()
	p = list(rint())
	pi = [i for i in range(n)]
	pi.sort(key=lambda x: p[x])
	Min = 10 ** 9
	Max = -1
	ans = []
	for i in range(n):
		Min = min(Min, pi[i])
		Max = max(Max, pi[i])
		if Max - Min > i:
			ans.append('0')
		else:
			ans.append('1')
	print(''.join(ans))


t = int(input())
for t_i in range(t):
	n = int(input())
	P = input().split()
	(l, r) = (-1, -1)
	for i in range(n):
		P[i] = int(P[i])
		if P[i] == 1:
			l = i
			r = i
	max_seen = 1
	beaut = ['1']
	for _ in range(n - 1):
		if l == 0:
			l_cand = 10 ** 8
		else:
			l_cand = P[l - 1]
		if r == n - 1:
			r_cand = 10 ** 8
		else:
			r_cand = P[r + 1]
		if r_cand > l_cand:
			l -= 1
			max_seen = max(l_cand, max_seen)
		else:
			r += 1
			max_seen = max(r_cand, max_seen)
		beaut.append('1' if max_seen == r - l + 1 else '0')
	print(''.join(beaut))


n = int(input())
for i in range(n):
	t = int(input())
	l = list(map(int, input().split()))
	dp = {i + 1: 0 for i in range(t)}
	ans = ''
	for j in range(t):
		dp[l[j]] = j + 1
	z = float('inf')
	s = 0
	for j in range(1, t + 1):
		s = s + dp[j]
		z = min(dp[j], z)
		if j * (j + 1) // 2 == s - j * (z - 1):
			ans = ans + '1'
		else:
			ans = ans + '0'
	print(ans)


t = int(input())
for w in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	if n == 1:
		if a[0] == 1:
			print(1)
		else:
			print(0)
		continue
	pos = [0 for i in range(n)]
	ans = [0 for i in range(n)]
	for i in range(n):
		pos[a[i] - 1] = i
	ans[0] = 1
	l = pos[0]
	r = pos[0]
	for i in range(1, n):
		if pos[i] > r:
			r = pos[i]
		elif pos[i] < l:
			l = pos[i]
		if r - l == i:
			ans[i] = 1
	for i in range(n):
		print(ans[i], end='')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	lst = [int(x) for x in input().split()]
	l2 = [0 for x in range(n)]
	for i in range(n):
		l2[lst[i] - 1] = i
	small = n
	big = 0
	ans = ''
	for i in range(n):
		small = min(small, l2[i])
		big = max(big, l2[i])
		if big - small == i:
			ans += '1'
		else:
			ans += '0'
	print(ans)


MOD = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
for _ in range(ii()):
	n = ii()
	l = il()
	d = dict()
	for i in range(n):
		d[l[i]] = i
	mx = d[1]
	mn = d[1]
	s = ['1'] * n
	for i in range(2, n + 1):
		mx = max(mx, d[i])
		mn = min(mn, d[i])
		if mx - mn + 1 == i:
			s[i - 1] = '1'
		else:
			s[i - 1] = '0'
	print(''.join(s))


t = int(input())
while t:
	t -= 1
	mark = {}
	n = int(input())
	a = list(map(int, input().split()))
	for i in range(n):
		mark[a[i]] = i
	l = r = mark[1]
	ans = '1'
	for i in range(2, n + 1):
		pos = mark[i]
		if pos > l and pos < r and (r - l + 1 == i):
			ans += '1'
		elif pos < l and abs(pos - l) == 1 and (r - pos + 1 == i):
			ans += '1'
			l = pos
		elif pos > r and abs(pos - r) == 1 and (pos - l + 1 == i):
			ans += '1'
			r = pos
		elif pos < l:
			l = pos
			ans += '0'
		elif pos > r:
			r = pos
			ans += '0'
		else:
			ans += '0'
	print(ans)


import sys
reader = (map(int, line.split()) for line in sys.stdin)
input = reader.__next__
(t,) = input()
for _ in range(t):
	(n,) = input()
	a = list(input())
	ans = ['1']
	l = r = a.index(1)
	curr_max = 1
	for i in range(2, n + 1):
		if l == 0:
			r += 1
			curr_max = max(curr_max, a[r])
		elif r == n - 1:
			l -= 1
			curr_max = max(curr_max, a[l])
		elif a[l - 1] < a[r + 1]:
			l -= 1
			curr_max = max(curr_max, a[l])
		else:
			r += 1
			curr_max = max(curr_max, a[r])
		ans.append('1' if curr_max == i else '0')
	print(''.join(ans))


t = int(input().strip())

def find(a, b, p, v):
	while b != p[b]:
		nxt = p[b]
		p[b] = a
		b = nxt
	p[b] = a
	val[a] += val[b]
for _ in range(t):
	n = int(input().strip())
	nums = dict()
	for (index, i) in enumerate(input().strip().split()):
		num = int(i)
		nums[num - 1] = index
	if n == 1:
		print(1)
	else:
		p = [-1 for i in range(n)]
		val = [0 for i in range(n)]
		ans = [0 for i in range(n)]
		for i in range(n):
			each_num = nums[i]
			val[each_num] = 1
			p[each_num] = each_num
			if each_num == 0:
				if p[each_num + 1] > -1:
					find(0, 1, p, val)
			elif each_num == n - 1:
				if p[each_num - 1] > -1:
					find(n - 1, n - 2, p, val)
			else:
				if p[each_num + 1] > -1:
					find(each_num, each_num + 1, p, val)
				if p[each_num - 1] > -1:
					find(each_num, each_num - 1, p, val)
			if val[each_num] == i + 1:
				ans[i] = 1
		for j in ans:
			print(j, end='')
		print()


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

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

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = I()
	rr = []
	for _ in range(t):
		n = I()
		a = LI_()
		d = {}
		for (i, c) in enumerate(a):
			d[c] = i
		l = r = d[0]
		t = [1]
		for i in range(1, n):
			l = min(l, d[i])
			r = max(r, d[i])
			t.append(IF(r - l == i, 1, 0))
		rr.append(JA(t, ''))
	return JA(rr, '\n')
print(main())


from itertools import combinations
import sys
input = sys.stdin.readline
INF = 10 ** 9
t = int(input())
for i in range(t):
	n = int(input())
	a = [INF] + [int(item) for item in input().split()] + [INF]
	ans = [1]
	l = r = a.index(1)
	max_val = 1
	for i in range(2, n + 1):
		if i == max(max_val, a[l - 1]):
			ans.append(1)
			l -= 1
			max_val = i
		elif i == max(max_val, a[r + 1]):
			ans.append(1)
			r += 1
			max_val = i
		elif a[l - 1] < a[r + 1]:
			ans.append(0)
			max_val = max(max_val, a[l - 1])
			l -= 1
		else:
			ans.append(0)
			max_val = max(max_val, a[r + 1])
			r += 1
	print(''.join([str(item) for item in ans]))


t = int(input())
while t > 0:
	n = int(input())
	p = map(int, input().split())
	p = list(p)
	pos = [0] * (n + 5)
	v = [0] * (n + 5)
	cnt = 0
	for i in range(n):
		pos[p[i]] = i + 1
	for i in range(1, n + 1):
		P = pos[i]
		v[P] = 1
		cnt += v[P - 1] + v[P + 1]
		if cnt + 1 == i:
			print(1, end='')
		else:
			print(0, end='')
	print()
	t -= 1


from operator import itemgetter
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	for (i, j) in enumerate(a):
		b.append((j, i))
	b.sort(key=itemgetter(0))
	mi = n
	ma = -1
	c = [0] * n
	temp = 0
	for i in b:
		mi = min(mi, i[1])
		ma = max(ma, i[1])
		if ma - mi == temp:
			c[temp] = 1
		temp += 1
	print(''.join(map(str, c)))


import os
import sys
from io import BytesIO, IOBase
from itertools import accumulate

def solution(arr, n):
	(minx, maxx) = ([0] * (n + 1), [0] * (n + 1))
	for i in range(1, n + 1):
		minx[arr[i]] = i
		maxx[arr[i]] = i
	for i in range(2, n + 1):
		minx[i] = min(minx[i], minx[i - 1])
		maxx[i] = max(maxx[i], maxx[i - 1])
	res = ''.join(['1' if maxx[i] - minx[i] + 1 == i else '0' for i in range(1, n + 1)])
	write(res)

def main():
	for _ in range(r_int()):
		n = r_int()
		arr = r_array()
		arr.insert(0, 0)
		solution(arr, n)
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))

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

def write(*args, end='\n'):
	for x in args:
		sys.stdout.write(str(x) + ' ')
	sys.stdout.write(end)

def r_array():
	return [int(x) for x in input().split()]

def r_int():
	return int(input())
main()


t = int(input())
for _ in range(t):
	n = int(input())
	p = [int(i) for i in input().split()]
	d = {}
	for i in range(n):
		d[p[i]] = i
	(l, r) = (d[1], d[1])
	ans = [1]
	num = 2
	while num <= n:
		idx = d[num]
		if idx > r:
			r = idx
		if l > idx:
			l = idx
		if r - l <= num - 1:
			ans.append(1)
		else:
			ans.append(0)
		num += 1
	print(''.join([str(i) for i in ans]))


import sys
input = lambda : sys.stdin.readline().strip('\r\n')
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	p = [0] * (2 * 10 ** 5)
	for i in range(n):
		p[a[i] - 1] = i
	l = n
	r = 0
	ans = []
	for i in range(n):
		l = min(l, p[i])
		r = max(r, p[i])
		if r - l == i:
			ans.append('1')
		else:
			ans.append('0')
	print(''.join(ans))


I = input
t = int(I())
for i in range(t):
	n = int(I())
	ar = [int(x) for x in I().split()]
	m = [0] * (n + 1)
	ans = ''
	for j in range(n):
		m[ar[j]] = j
	(mx, mn) = (0, n)
	for j in range(1, n + 1):
		mx = max(m[j], mx)
		mn = min(m[j], mn)
		l = mx - mn + 1
		if l == j:
			ans += '1'
		else:
			ans += '0'
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	D = [0 for _ in range(n + 1)]
	for i in range(n):
		D[A[i]] = i
	mini = n
	maxi = -1
	for i in range(1, n + 1):
		mini = min(mini, D[i])
		maxi = max(maxi, D[i])
		if maxi - mini == i - 1:
			print(1, end='')
		else:
			print(0, end='')
	print()


def get_ans_string(p):
	is_pretty = [0] * len(p)
	ind_of = [-1] * len(p)
	for i in range(len(p)):
		p[i] -= 1
		ind_of[p[i]] = i
	(leftest, rightest) = (ind_of[0], ind_of[0])
	cur_num = 0
	while cur_num < len(p):
		ind = ind_of[cur_num]
		if ind < leftest:
			leftest = ind
		if ind > rightest:
			rightest = ind
		if cur_num == rightest - leftest:
			is_pretty[cur_num] = 1
		cur_num += 1
	return ''.join(map(str, is_pretty))
test_count = int(input())
for _ in range(test_count):
	n = int(input())
	p = list(map(int, input().split()))
	print(get_ans_string(p))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split(' ')))
	idx = [None] * (n + 1)
	for i in range(n):
		idx[a[i]] = i + 1
	ans = ['0'] * n
	ans[0] = '1'
	ans[-1] = '1'
	curr_max = idx[1]
	curr_min = idx[1]
	for m in range(2, n):
		curr_max = max(curr_max, idx[m])
		curr_min = min(curr_min, idx[m])
		if m == curr_max - curr_min + 1:
			ans[m - 1] = '1'
	print(''.join(ans))


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
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
mod = 1000000007

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 zerolist(n):
	return [0] * n

def nextline():
	out('\n')

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

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

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

def power(x, y, p):
	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

def solve():
	n = int(inp())
	a = lis()
	pos = [0] * (n + 1)
	for i in range(n):
		pos[a[i]] = i + 1
	need = 0
	left = pos[1]
	right = pos[1]
	have = 0
	ans = [False] * (n + 1)
	ans[1] = True
	for i in range(2, n + 1):
		if pos[i] < left:
			need += left - pos[i]
			left = pos[i]
			if i != 2:
				have += 1
		elif pos[i] > right:
			need += pos[i] - right
			right = pos[i]
			if i != 2:
				have += 1
		else:
			have += 1
		if have == right - (left + 1):
			ans[i] = True
	s = []
	for i in range(1, n + 1):
		if ans[i]:
			s.append('1')
		else:
			s.append('0')
	print(''.join(s))
testcase(int(inp()))


for i in range(int(input())):
	(n, s) = (int(input()), [])
	a = [int(x) for x in input().split()]
	a = [(a[i], i + 1) for i in range(n)]
	a.sort(key=lambda x: x[0])
	mi = ma = a[0][1]
	for j in range(n):
		mi = min(mi, a[j][1])
		ma = max(ma, a[j][1])
		s.append('1' if ma - mi == j else '0')
	print(''.join(s))


t = int(input())
for rep in range(0, t):
	n = int(input())
	p = input().split()
	p = list(map(int, p))
	poz = [None] * (n + 1)
	for i in range(0, n):
		poz[p[i]] = i
	s = {None}
	minim = 1000000
	maxim = -1000000
	for i in range(1, n + 1):
		s.add(poz[i])
		minim = min(minim, poz[i])
		maxim = max(maxim, poz[i])
		if maxim - minim + 1 == i:
			print(1, end='')
		else:
			print(0, end='')
	print('')


t = int(input())
for _ in range(t):
	n = int(input())
	seq = input().split()
	d = {}
	for i in range(n):
		a = int(seq[i])
		if a == ' ':
			continue
		d[a] = i
	soln = [0] * n
	(r, l) = (d[1], d[1])
	for i in range(1, n + 1):
		pos = d[i]
		if pos > r:
			r = pos
		if pos < l:
			l = pos
		if i == r - l + 1:
			soln[i - 1] = 1
	for i in soln:
		print(i, end='')
	print()


for _ in range(int(input())):
	n = int(input())
	l1 = list(map(int, input().split()))
	arr = [0] * n
	for i in range(n):
		arr[l1[i] - 1] = i
	l = n
	r = 0
	s = ''
	for i in range(n):
		l = min(l, arr[i])
		r = max(r, arr[i])
		if r - l == i:
			s += '1'
		else:
			s += '0'
	print(s)


n = int(input())
for i in range(n):
	v = int(input())
	l = list(map(int, input().split()))
	s = ''
	da = {}
	e = v
	d = 0
	for j in range(v):
		da[l[j]] = j
	for t in range(1, v + 1):
		e = min(e, da[t])
		d = max(d, da[t])
		if d - e + 1 > t:
			s += '0'
		else:
			s += '1'
	print(s)


for _ in range(int(input())):
	v = int(input())
	a = list(map(int, input().split()))
	k = [0] * v
	mn = 999999999999
	mx = 0
	w = ''
	for i in range(0, v):
		k[a[i] - 1] = i
	for i in range(0, v):
		mn = min(k[i], mn)
		mx = max(k[i], mx)
		if mx - mn == i:
			w = w + '1'
		else:
			w = w + '0'
	print(w)


import sys

class BBeautifulNumbers:

	def solve(self):
		for _ in range(int(input())):
			n = int(input())
			p = [int(_) - 1 for _ in input().split()]
			mn_index = [float('inf')] * n
			mx_index = [-float('inf')] * n
			prev = [0] * n
			for i in range(n):
				prev[p[i]] = i
			for i in range(n):
				mn_index[i] = min(mn_index[i - 1], prev[i])
				mx_index[i] = max(mx_index[i - 1], prev[i])
			ans = ['0'] * n
			for i in range(n):
				(l, r) = (mn_index[i], mx_index[i])
				ans[i] = '1' if r - l + 1 == i + 1 else '0'
			print(''.join(ans))
solver = BBeautifulNumbers()
input = sys.stdin.readline
solver.solve()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	di = [0] * (n + 1)
	for i in range(n):
		di[a[i]] = i
	a = ['1'] * n
	cur_min = di[1]
	cur_max = di[1]
	for i in range(2, n):
		next = di[i]
		if next > cur_max:
			cur_max = next
		elif next < cur_min:
			cur_min = next
		if cur_max - cur_min + 1 == i:
			a[i - 1] = '1'
		else:
			a[i - 1] = '0'
	print(''.join(a))


t = int(input())
t_result = []
for _ in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	positions = [0] * n
	for i in range(n):
		positions[p[i] - 1] = i
	result = [0] * n
	prev_idx = positions[0]
	result[0] = 1
	(left, right) = (prev_idx, prev_idx)
	cur_num = 1
	while cur_num < n:
		cur_idx = positions[cur_num]
		if cur_idx > right:
			right = cur_idx
		elif cur_idx < left:
			left = cur_idx
		if right - left > cur_num:
			result[cur_num] = 0
		else:
			result[cur_num] = 1
		cur_num += 1
	t_result.append(result)
for i in range(t):
	print(''.join(list(map(str, t_result[i]))))


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	index = [-1] * (n + 1)
	for j in range(n):
		index[arr[j]] = j + 1
	l = index[1]
	r = index[1]
	ans = list()
	ans.append(1)
	for j in range(2, n + 1):
		if index[j] > r:
			r = index[j]
		elif index[j] < l:
			l = index[j]
		if r - l == j - 1:
			ans.append(1)
		else:
			ans.append(0)
	for j in range(n):
		print(ans[j], end='')
	print()


def solve(arr):
	res = [0] * len(arr)
	res[0] = 1
	positions = dict()
	for (i, el) in enumerate(arr):
		positions[el] = i
	l = r = positions[1]
	for i in range(2, len(arr) + 1):
		if positions[i] >= l and positions[i] <= r:
			res[i - 1] = 1 if r - l + 1 == i else 0
		elif positions[i] == l - 1:
			l -= 1
			res[i - 1] = 1 if r - l + 1 == i else 0
		elif positions[i] == r + 1:
			r += 1
			res[i - 1] = 1 if r - l + 1 == i else 0
		else:
			res[i - 1] = 0
			if positions[i] < l:
				l = positions[i]
			else:
				r = positions[i]
	return ''.join(list(map(str, res)))
tests = int(input())
res = []
for i in range(tests):
	input()
	inp = list(map(int, input().split()))
	res.append(solve(inp))
print('\n'.join(res))


t = int(input())
for _ in range(t):
	n = int(input())
	nums = list(map(int, input().strip().split()))
	ind = [0] * n
	for (i, num) in enumerate(nums):
		ind[num - 1] = i
	l = ind[0]
	r = ind[0]
	lack = 0
	output = ''
	for i in ind:
		if i < l:
			lack += l - i - 1
			l = i
		elif i > r:
			lack += i - r - 1
			r = i
		elif lack > 0:
			lack -= 1
		if not lack:
			output += '1'
		else:
			output += '0'
	print(output)


t = int(input())
for i in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	index = {}
	for i in range(n):
		index[p[i]] = i
	l = index[1]
	r = index[1]
	res = '1'
	for i in range(2, n + 1):
		num = index[i]
		if num < l:
			l = num
		elif num > r:
			r = num
		if 1 + r - l == i:
			res += '1'
		else:
			res += '0'
	print(res)


import sys

def inp():
	return sys.stdin.readline().strip()
for _ in range(int(inp())):
	n = int(inp())
	p = list(map(int, inp().split()))
	s = set([1])
	mx = 1
	mn = 1
	l = r = p.index(1)
	ll = ['0'] * n
	ll[0] = '1'
	while l > 0 or r < n - 1:
		if r < n - 1 and l > 0:
			if p[r + 1] < p[l - 1]:
				r += 1
				mn = min(mn, p[r])
				mx = max(mx, p[r])
				s.add(p[r])
				if mn == 1 and mx == len(s):
					ll[mx - 1] = '1'
			else:
				l -= 1
				s.add(p[l])
				mn = min(p[l], mn)
				mx = max(p[l], mx)
				if mn == 1 and mx == len(s):
					ll[mx - 1] = '1'
		elif l > 0:
			l -= 1
			s.add(p[l])
			mn = min(p[l], mn)
			mx = max(p[l], mx)
			if mn == 1 and mx == len(s):
				ll[mx - 1] = '1'
		elif r < n - 1:
			r += 1
			mn = min(mn, p[r])
			mx = max(mx, p[r])
			s.add(p[r])
			if mn == 1 and mx == len(s):
				ll[mx - 1] = '1'
	print(''.join(ll))


import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

def solve2():
	N = int(input())
	ans = ''
	L = list(map(int, input().split()))
	D = dict()
	for (i, l) in enumerate(L):
		D[l] = i
	l = N + 2
	r = 0
	painted = 0
	for i in range(1, N + 1):
		pos = D[i]
		l = min(l, pos)
		r = max(r, pos)
		painted += 1
		if r - l + 1 == painted:
			ans += '1'
		else:
			ans += '0'
	print(ans)
T = int(input())
for _ in range(T):
	solve2()


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	ans = '1'
	s = 0
	l = 0
	r = 0
	for i in range(n):
		if a[i] == 1:
			l = i
			r = i
	for i in range(2, n + 1):
		s += i
		while l - 1 >= 0 and a[l - 1] <= i:
			l = l - 1
			s -= a[l]
		while r + 1 < n and a[r + 1] <= i:
			r += 1
			s -= a[r]
		if s == 0:
			ans += '1'
		else:
			ans += '0'
	print(ans)
for _ in range(int(input())):
	solve()


for _ in range(int(input())):
	N = int(input())
	L = list(map(int, input().split()))
	Hash = [0] * N
	for i in range(N):
		Hash[L[i] - 1] = i
	High = -1
	Low = N + 1
	for i in range(N):
		High = max(High, Hash[i])
		Low = min(Low, Hash[i])
		if High - Low == i:
			print(1, end='')
		else:
			print('0', end='')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	p = [int(x) for x in input().split()]
	idx = dict()
	for i in range(n):
		idx[p[i]] = i
	ans = [n]
	l = 0
	r = n - 1
	one = idx[1]
	for i in range(n, 1, -1):
		j = idx[i]
		if j > one:
			r = min(r, j - 1)
		else:
			l = max(l, j + 1)
		if r - l + 1 == i - 1:
			ans.append(i - 1)
	ans2 = ['0'] * n
	for x in ans:
		ans2[x - 1] = '1'
	print(''.join(ans2))


from functools import reduce
import os
import sys
from collections import *
from math import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def arr():
	return [int(i) for i in input().split()]

def sarr():
	return [int(i) for i in input()]

def starr():
	return [str(x) for x in input().split()]

def inn():
	return int(input())

def svalue():
	return tuple(map(str, input().split()))

def parr():
	return [value() for i in range(n)]
mo = 1000000007
inf = 1e+18
div = 998244353
for _ in range(inn()):
	n = inn()
	a = arr()
	d = defaultdict(int)
	for i in range(n):
		d[a[i] - 1] = i
	ans = []
	l = n
	h = 0
	for i in range(n):
		l = min(l, d[i])
		h = max(h, d[i])
		if h - l == i:
			ans += [1]
		else:
			ans += [0]
	print(*ans, sep='')


t = int(input())
for _ in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	idx = 2
	ind = [0 for _ in range(n + 1)]
	for i in range(n):
		ind[p[i]] = i
	min_idx = ind[1]
	max_idx = ind[1]
	ans = [0 for _ in range(n)]
	ans[0] = 1
	ans[-1] = 1
	for i in range(n):
		(max_idx, min_idx) = (max(max_idx, ind[i + 1]), min(min_idx, ind[i + 1]))
		if i == max_idx - min_idx:
			ans[i] = 1
	res = ''
	for elem in ans:
		res += str(elem)
	print(res)


t = int(input())
while t:
	t -= 1
	n = int(input())
	p = list(map(int, input().split()))
	m = [False for i in range(n)]
	l = r = p.index(1)
	ava = set([1])
	mx = 1
	m[0] = True
	while l >= 0 and r < n:
		nl = l - 1
		nr = r + 1
		if nl >= 0 and nr < n:
			if p[nl] < p[nr]:
				l -= 1
				ava.add(p[l])
				mx = max(mx, p[l])
			else:
				r += 1
				ava.add(p[r])
				mx = max(mx, p[r])
		elif nl >= 0:
			l -= 1
			ava.add(p[l])
			mx = max(mx, p[l])
		elif nr < n:
			r += 1
			ava.add(p[r])
			mx = max(mx, p[r])
		if mx == len(ava):
			m[mx - 1] = True
		if l == 0 and r == n - 1:
			break
	for f in m:
		print('1' if f else '0', end='')
	print()


for _ in range(int(input())):
	n = int(input())
	l = [0 for _ in range(n + 1)]
	arr = list(map(int, input().split()))
	for i in range(0, n):
		l[arr[i]] = i + 1
	mx = l[1]
	mn = l[1]
	ans = ['1' for _ in range(n)]
	for m in range(2, n + 1, 1):
		mx = max(mx, l[m])
		mn = min(mn, l[m])
		if mx - mn + 1 != m:
			ans[m - 1] = '0'
	print(''.join(ans))


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	a_indexed = [(a[i], i + 1) for i in range(n)]
	a_indexed.sort()
	ans = ['1']
	cur_max = cur_min = a_indexed[0][1]
	for i in range(1, n):
		if a_indexed[i][1] > cur_max:
			cur_max = a_indexed[i][1]
		if a_indexed[i][1] < cur_min:
			cur_min = a_indexed[i][1]
		ans.append('1' if cur_max - cur_min == i else '0')
	print(''.join(ans))


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
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')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 10 ** 9 + 7
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
for _ in range(Int()):
	n = Int()
	a = array()
	ind = {a[i]: i + 1 for i in range(n)}
	low = ind[1]
	high = ind[1]
	ans = [1]
	for i in range(2, n + 1):
		low = min(ind[i], low)
		high = max(ind[i], high)
		if high - low + 1 == i:
			ans.append(1)
		else:
			ans.append(0)
	print(*ans, sep='')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	pos = {}
	for i in range(n):
		pos[a[i]] = i
	po = []
	for key in sorted(pos.keys()):
		po.append(pos[key])
	st = set()
	(mx, mn) = (0, 0)
	ans = []
	for i in range(n):
		if i == 0:
			(mx, mn) = (po[i], po[i])
			st.add(po[i])
			ans.append('1')
		else:
			mx = max(mx, po[i])
			mn = min(mn, po[i])
			st.add(po[i])
			if len(st) + mn - 1 == mx:
				ans.append('1')
			else:
				ans.append('0')
	print(''.join(ans))


import sys
from collections import defaultdict as dd

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

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

def l():
	return list(sp())

def strl():
	return list(strsp())

def sp():
	return map(int, data().split())

def strsp():
	return map(str, data().split())
for _ in range(int(data())):
	n = int(data())
	p = l()
	a = dd()
	for i in range(n):
		a[p[i]] = i
	b = []
	c = []
	for i in range(1, n + 1):
		c.append(a[i])
	(e, f) = (0, c[0])
	for i in range(n):
		if e < c[i]:
			e = c[i]
		if f > c[i]:
			f = c[i]
		if abs(e - f) == i:
			b.append('1')
		else:
			b.append('0')
	print(''.join(b))


t = int(input())
for i in range(t):
	n = int(input())
	b = list(map(int, input().split()))
	c = [0] * (n + 1)
	d = []
	for j in range(n):
		c[b[j]] = j
	q = -1
	r = 100000000
	for j in range(1, n + 1):
		q = max(q, c[j])
		r = min(r, c[j])
		if q - r + 1 == j:
			d.append('1')
		else:
			d.append('0')
	print(''.join(d))


import sys
import math
import bisect
sys.setrecursionlimit(1000000000)

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

def iinput():
	return int(input())

def finput():
	return float(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())

def main():
	n = iinput()
	c = rlinput()
	(q, res, w, e) = ([0] * n, ['0'] * n, 0, n)
	for i in range(n):
		q[c[i] - 1] = i
	for i in range(n):
		w = max(q[i], w)
		e = min(q[i], e)
		if w <= i + e:
			res[i] = '1'
	print(''.join(res))
for j in range(int(input())):
	main()


import sys
input = sys.stdin.readline
t = int(input())
while t:
	n = int(input())
	l = list(map(int, input().split()))
	pre = [0]
	li = [0] * (n + 1)
	for i in range(n):
		li[l[i]] = i
		pre.append(pre[-1] + l[i])
	mi = li[1]
	mx = li[1]
	for i in range(1, n + 1):
		mi = min(mi, li[i])
		mx = max(mx, li[i])
		sum = pre[mx + 1] - pre[mi]
		if sum == i * (i + 1) // 2:
			print(1, end='')
		else:
			print(0, end='')
	print()
	t -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	d = []
	for i in range(n):
		d.append([a[i], i])
	d.sort()
	ans = '1'
	m = 0
	sm = 0
	sp = 0
	for i in range(1, n):
		if d[i][1] - d[0][1] > 0:
			sp = max(sp, d[i][1] - d[0][1])
		else:
			sm = min(d[i][1] - d[0][1], sm)
		m = max(sp, -sm)
		if d[i][0] - 1 >= abs(d[0][1] - d[i][1]) and m <= d[i][0] - 1 and (sp - sm <= d[i][0] - 1):
			ans = ans + '1'
		else:
			ans = ans + '0'
	print(ans)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	left = n
	right = 0
	for i in range(n):
		d[l[i]] = i
	ans = ''
	for i in range(1, n + 1):
		left = min(left, d[i])
		right = max(right, d[i])
		if right - left + 1 == i:
			ans += '1'
		else:
			ans += '0'
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	pos = {}
	for i in range(n):
		pos[p[i]] = i + 1
	(l, r) = (pos[1], pos[1])
	values = '1'
	for i in range(2, n + 1):
		num = pos[i]
		if num > r:
			r = num
		elif num < l:
			l = num
		if r - l + 1 == i:
			values += '1'
		else:
			values += '0'
	print(values)


q = int(input())
for t in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	ma = 1
	ans = '1'
	uk1 = a.index(1)
	uk2 = uk1
	while uk2 - uk1 + 1 != n:
		if uk2 == n - 1:
			uk1 -= 1
			ma = max(ma, a[uk1])
			if ma == uk2 - uk1 + 1:
				ans = ans + '1'
			else:
				ans = ans + '0'
		elif uk1 == 0:
			uk2 += 1
			ma = max(ma, a[uk2])
			if ma == uk2 - uk1 + 1:
				ans = ans + '1'
			else:
				ans = ans + '0'
		elif a[uk1 - 1] < a[uk2 + 1]:
			uk1 -= 1
			ma = max(ma, a[uk1])
			if ma == uk2 - uk1 + 1:
				ans = ans + '1'
			else:
				ans = ans + '0'
		else:
			uk2 += 1
			ma = max(ma, a[uk2])
			if ma == uk2 - uk1 + 1:
				ans = ans + '1'
			else:
				ans = ans + '0'
	print(ans)


def f(s):
	for i in range(len(s) - 1):
		if s[i] == s[i + 1] and s[i] != '?':
			return True
	return False
z = int(input())
for zz in range(z):
	n = int(input())
	a = [int(i) for i in input().split()]
	si = a.index(1)
	res = ['1']
	m = 2
	rI = si
	lI = si
	d = dict()
	for i in range(len(a)):
		d[a[i]] = i
	while m < n:
		t = d[m]
		if t > rI:
			rI = t
		elif t < lI:
			lI = t
		if rI - lI + 1 == m:
			res.append('1')
		else:
			res.append('0')
		m += 1
	if n > 1:
		res.append('1')
	print(''.join(res))


N = int(input())
for _ in range(N):
	nn = int(input())
	nums = list(map(int, input().split(' ')))
	l = 0
	r = 0
	ans = [0] * nn
	bol = [False] * nn
	for i in range(nn):
		if nums[i] == 1:
			l = i
			r = i
			ans[0] = 1
			break
	tem = 1
	max_n = 1
	while r - l + 1 <= nn:
		if l - 1 >= 0:
			a = nums[l - 1]
		else:
			a = -1
		if r + 1 < nn:
			b = nums[r + 1]
		else:
			b = -1
		if a == -1:
			r += 1
			max_n = max(max_n, b)
		if b == -1:
			l -= 1
			max_n = max(max_n, a)
		if a > b and b != -1:
			r += 1
			max_n = max(max_n, b)
		if a < b and a != -1:
			l -= 1
			max_n = max(max_n, a)
		if max_n > r - l + 1:
			ans[r - l] = 0
		if max_n == r - l + 1:
			ans[r - l] = 1
	ans[-1] = 1
	res = list(map(lambda x: str(x), ans))
	res = ''.join(res)
	print(res)


T = int(input(''))
for _ in range(T):
	n = int(input(''))
	p = list(map(int, input('').split(' ')))
	l = [0] * (n + 1)
	for i in range(n):
		l[p[i]] = i
	mn = l[1]
	mx = l[1]
	for i in range(1, n + 1, 1):
		if mx - mn + 1 == i:
			print('1', end='')
		else:
			print('0', end='')
		if i < n:
			if l[i + 1] < mn:
				mn = l[i + 1]
			if l[i + 1] > mx:
				mx = l[i + 1]
	print('')


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	pos = [0 for i in range(n + 1)]
	for i in range(len(arr)):
		pos[arr[i] - 1] = i
	l = n
	r = 0
	ans = ''
	for i in range(n):
		l = min(l, pos[i])
		r = max(r, pos[i])
		if r - l == i:
			ans += '1'
		else:
			ans += '0'
	print(ans)


def beautiful_number(num, num_length):
	pos_array = [0] * num_length
	result = ''
	for i in range(num_length):
		pos_array[int(num[i]) - 1] = i + 1
	minimum = pos_array[0]
	maximum = pos_array[0]
	for i in range(0, num_length):
		if maximum - minimum == i:
			result += '1'
		else:
			result += '0'
		if i != num_length - 1:
			if pos_array[i + 1] > maximum:
				maximum = pos_array[i + 1]
			if pos_array[i + 1] < minimum:
				minimum = pos_array[i + 1]
	return result

def main():
	num_of_tests = eval(input())
	for i in range(num_of_tests):
		num_length = eval(input())
		test = input()
		print(beautiful_number(test.split(), num_length))
main()


x = int(input())
arr = dict()
while x:
	input()
	keylist = list(map(int, input().split()))
	keyDict = dict()
	i = 0
	for k in keylist:
		keyDict[k] = i
		i += 1
	i = 0
	count = 0
	highestPast = -1
	lowestPast = -1
	for k in range(1, len(keyDict.keys()) + 1):
		count += 1
		if k == 1:
			highestPast = keyDict[k]
			lowestPast = keyDict[k]
		elif highestPast < keyDict[k]:
			highestPast = keyDict[k]
		elif lowestPast > keyDict[k]:
			lowestPast = keyDict[k]
		if highestPast - lowestPast == count - 1:
			print(1, end='')
		else:
			print(0, end='')
	print('')
	x -= 1


T = int(input())
MAX = 3 * 10 ** 5 + 10
for t in range(1, T + 1):
	n = int(input())
	a = list(map(int, input().split()))
	stack = []
	nextLargerNumber = [n for i in range(n)]
	for i in range(n):
		while stack and stack[-1][0] < a[i]:
			(x, y) = stack.pop()
			nextLargerNumber[y] = i
		stack.append([a[i], i])
	b = a[::-1]
	stack = []
	prevLargerNumber = [-1 for i in range(n)]
	for i in range(n):
		while stack and stack[-1][0] < b[i]:
			(x, y) = stack.pop()
			prevLargerNumber[n - y - 1] = n - i - 1
		stack.append((b[i], i))
	isBeautiful = [1 for i in range(n + 1)]
	for i in range(n):
		if nextLargerNumber[i] - prevLargerNumber[i] - 1 >= a[i]:
			isBeautiful[a[i]] = 1
		else:
			isBeautiful[a[i]] = 0
	for i in isBeautiful[1:]:
		print(i, end='')
	print('')


def main():
	n = int(input())
	p = list(map(int, input().split()))
	idx = [0] * n
	for i in range(n):
		idx[p[i] - 1] = i
	ans = ''
	left = n
	right = 0
	for i in range(n):
		left = min(left, idx[i])
		right = max(right, idx[i])
		if right - left == i:
			ans += '1'
		else:
			ans += '0'
	return ans
t = int(input())
for i in range(t):
	print(main())


for _ in [0] * int(input()):
	n = int(input())
	a = [0] * n
	ans = ''
	i = m = j = 0
	for x in map(int, input().split()):
		a[x - 1] = i
		i += 1
	for x in a:
		n = min(n, x)
		m = max(m, x)
		if m - n > j:
			ans += '0'
		else:
			ans += '1'
		j += 1
	print(ans)


t = int(input())
for case in range(t):
	n = int(input())
	p = [int(x) for x in input().split(' ')]
	ans = ['0'] * n
	(l, r) = (p.index(1), p.index(1))
	s = set([1])
	m = max(s)
	ans[0] = '1'
	while len(s) < n:
		if l == 0:
			r += 1
			s.add(p[r])
			m = max(m, p[r])
		elif r == n - 1:
			l -= 1
			s.add(p[l])
			m = max(m, p[l])
		elif p[l - 1] < p[r + 1]:
			l -= 1
			s.add(p[l])
			m = max(m, p[l])
		else:
			r += 1
			s.add(p[r])
			m = max(m, p[r])
		if m == len(s):
			ans[m - 1] = '1'
	print(''.join(ans))


import collections
for t in range(int(input())):
	n = int(input())
	ans = [1] + [0] * (n - 1)
	p = list(map(int, input().split()))
	(i, j, curr, m) = (p.index(1), 1, 1, 1)
	(l, r) = (i, i)
	while l >= 0 and r < n:
		if l and curr + p[l - 1] == (m + 2) * (m + 1) // 2:
			ans[m] = 1
			curr += p[l - 1]
			l -= 1
		elif r + 1 < n and curr + p[r + 1] == (m + 2) * (m + 1) // 2:
			ans[m] = 1
			curr += p[r + 1]
			r += 1
		elif l and r + 1 < n:
			(curr, l, r) = ((curr + p[l - 1], l - 1, r), (curr + p[r + 1], l, r + 1))[p[r + 1] < p[l - 1]]
		elif not l and r + 1 < n:
			(curr, l, r) = (curr + p[r + 1], l, r + 1)
		elif r + 1 == n and l:
			(curr, l, r) = (curr + p[l - 1], l - 1, r)
		else:
			break
		m += 1
	print(''.join([str(i) for i in ans]))