Doremy is asked to test $n$ contests. Contest $i$ can only be tested on day $i$. The difficulty of contest $i$ is $a_i$. Initially, Doremy's IQ is $q$. On day $i$ Doremy will choose whether to test contest $i$ or not. She can only test a contest if her current IQ is strictly greater than $0$.

If Doremy chooses to test contest $i$ on day $i$, the following happens:

if $a_i>q$, Doremy will feel she is not wise enough, so $q$ decreases by $1$;

otherwise, nothing changes.

If she chooses not to test a contest, nothing changes.

Doremy wants to test as many contests as possible. Please give Doremy a solution.


-----Input-----

The input consists of multiple test cases. The first line contains a single integer $t$ ($1\le t\le 10^4$) — the number of test cases. The description of the test cases follows.

The first line contains two integers $n$ and $q$ ($1 \le n \le 10^5$, $1 \le q \le 10^9$) — the number of contests and Doremy's IQ in the beginning.

The second line contains $n$ integers $a_1,a_2,\cdots,a_n$ ($1 \le a_i \le 10^9$) — the difficulty of each contest.

It is guaranteed that the sum of $n$ over all test cases does not exceed $10^5$.


-----Output-----

For each test case, you need to output a binary string $s$, where $s_i=1$ if Doremy should choose to test contest $i$, and $s_i=0$ otherwise. The number of ones in the string should be maximum possible, and she should never test a contest when her IQ is zero or less.

If there are multiple solutions, you may output any.


-----Examples-----

Input
5
1 1
1
2 1
1 2
3 1
1 2 1
4 2
1 4 3 1
5 2
5 1 2 4 3
Output
1
11
110
1110
01111


-----Note-----

In the first test case, Doremy tests the only contest. Her IQ doesn't decrease.

In the second test case, Doremy tests both contests. Her IQ decreases by $1$ after testing contest $2$.

In the third test case, Doremy tests contest $1$ and $2$. Her IQ decreases to $0$ after testing contest $2$, so she can't test contest $3$.

Difficulty: MEDIUM_HARD
Tags: Sorting

Constructive algorithms

Implementation

Greedy algorithms
Skill types: Sorting

Greedy algorithms

Starter code:

Solutions:
import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, q) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = ['0'] * n
	rest_q = 0
	for i in range(n - 1, -1, -1):
		if rest_q >= a[i]:
			b[i] = '1'
		elif rest_q < q and a[i] > rest_q:
			rest_q += 1
			b[i] = '1'
		else:
			pass
	print(''.join(b))


from collections import defaultdict, deque
import math
import bisect

def solve():
	(n, iq) = map(int, input().split())
	arr = list(map(int, input().split()))
	ans = [0 for _ in range(n)]
	curr = 0
	for i in range(n - 1, -1, -1):
		if curr < arr[i]:
			if curr < iq:
				curr += 1
				ans[i] = '1'
			else:
				ans[i] = '0'
		else:
			ans[i] = '1'
	print(''.join(ans))
t = int(input())
for _ in range(t):
	solve()


from collections import *
import copy

def main():
	for t in range(int(input())):
		(n, q) = map(int, input().split())
		a = list(map(int, input().split()))
		ans = []
		cnt = 0
		for i in range(n - 1, -1, -1):
			if a[i] > cnt and cnt < q:
				ans.append('1')
				cnt += 1
			elif a[i] <= cnt:
				ans.append('1')
			else:
				ans.append('0')
		print(''.join(reversed(ans)))
main()


t = int(input())
for tt in range(t):
	(n, q) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = ['0'] * n
	q1 = 0
	for r in range(n - 1, -1, -1):
		if a[r] <= q1:
			ans[r] = '1'
		elif q1 < q:
			q1 += 1
			ans[r] = '1'
		else:
			continue
	print(''.join(ans))


x = int(input())

def cal(n, m, arr):
	if m >= n:
		return '1' * n
	if m >= max(arr):
		return '1' * n
	if m < min(arr):
		return '1' * m + '0' * (n - m)
	if m == 0:
		return '0' * n
	if n == 1:
		return '1'
	ta = ['0'] * n
	ta[-1] = '1'
	t = 1
	for i in range(n - 2, -1, -1):
		if arr[i] > t:
			if t < m:
				t += 1
				ta[i] = '1'
			else:
				for j in range(i, -1, -1):
					if arr[j] <= t:
						ta[j] = '1'
				return ''.join(ta)
		else:
			ta[i] = '1'
	return ''.join(ta)
for jj in range(x):
	(n, m) = [int(i) for i in input().split(' ')]
	p = [int(i) for i in input().split(' ')]
	print(cal(n, m, p))


for _ in range(int(input())):
	(n, q) = map(int, input().split())
	ls = list(map(int, input().split()))
	ans = ['0'] * n
	iq = 0
	for i in range(n - 1, -1, -1):
		if ls[i] <= iq:
			ans[i] = '1'
		elif iq < q:
			iq += 1
			ans[i] = '1'
	print(''.join(ans))


for _ in range(int(input())):
	(length, iq) = map(int, input().split())
	list = [int(i) for i in input().split()]
	list.reverse()
	str = ''
	Q = 0
	for i in list:
		if i <= Q:
			str += '1'
		elif i > Q and Q < iq:
			str += '1'
			Q += 1
		elif i > Q and Q == iq:
			str += '0'
	print(str[::-1])


t = int(input())
for i in range(t):
	(n, q) = map(int, input().split())
	lst = list(map(int, input().split()))
	res = ['0'] * n
	intl = 0
	for i in range(n - 1, -1, -1):
		if lst[i] <= intl:
			res[i] = str(1)
		elif intl < q:
			intl += 1
			res[i] = str(1)
	print(''.join(res))


t = int(input())
for _ in range(t):
	(n, q) = map(int, input().split())
	a = list(map(int, input().split()))
	a.reverse()
	b = ''
	Q = 0
	for r in a:
		if r <= Q:
			b += '1'
		elif Q < q:
			Q += 1
			b += '1'
		else:
			b += '0'
	print(b[::-1])


for i in range(int(input())):
	(n, q) = list(map(int, input().split()))
	a = list(map(int, input().split()))[::-1]
	p = 0
	s = ['0'] * n
	for i in range(n):
		if a[i] > p:
			if p == q:
				continue
			p += 1
			s[i] = '1'
		else:
			s[i] = '1'
	print(''.join(s[::-1]))


for i in range(int(input())):
	(n, q) = map(int, input().split())
	a = list(map(int, input().split()))
	ll = 0
	a = a[::-1]
	ans = ''
	for i in a:
		if i > ll and ll < q:
			ans += '1'
			ll += 1
		elif i <= q:
			ans += '1'
		else:
			ans += '0'
	print(ans[::-1])


for t in ' ' * int(input()):
	(n, q) = map(int, input().split())
	l = [*map(int, input().split())][::-1]
	iq = 0
	s = ''
	for i in range(n):
		if l[i] <= iq:
			s += '1'
		elif q > iq:
			s += '1'
			iq += 1
		else:
			s += '0'
	print(s[::-1])


t = int(input())
for _ in range(t):
	(n, q) = map(int, input().split())
	arr = list(map(int, input().split()))[::-1]
	re = ''
	QQ = 0
	for i in range(n):
		if arr[i] <= QQ:
			re += '1'
		elif QQ < q:
			re += '1'
			QQ += 1
		else:
			re += '0'
	print(re[::-1])


for d in range(int(input())):
	(n, q) = map(int, input().split())
	l = list(map(int, input().split()))
	a = 0
	s = ''
	for i in range(n - 1, -1, -1):
		if l[i] <= a:
			s += '1'
		elif q > a:
			s += '1'
			a += 1
		else:
			s += '0'
	print(s[::-1])


for _ in range(int(input())):
	(n, q) = map(int, input().split())
	(*a,) = map(int, input().split())
	s = ['0'] * n
	q_now = 0
	for i in range(n - 1, -1, -1):
		if a[i] <= q_now:
			s[i] = '1'
		elif a[i] > q_now and q_now < q:
			s[i] = '1'
			q_now += 1
	print(''.join(s))


for i in range(int(input())):
	(n, q) = map(int, input().split())
	c = [int(j) for j in input().split()]
	s = ['0'] * n
	k = 0
	for j in reversed(range(n)):
		if c[j] > k:
			if k < q:
				k += 1
				s[j] = '1'
		else:
			k = max(k, c[j])
			s[j] = '1'
	print(''.join(s))


for _ in range(int(input())):
	(n, q) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = ['0'] * n
	c = 0
	for i in range(n - 1, -1, -1):
		if c < a[i]:
			if c == q:
				ans[i] = '0'
			else:
				ans[i] = '1'
				c += 1
		else:
			ans[i] = '1'
	print(''.join(ans))


for _ in range(int(input())):
	(n, q) = map(int, input().split())
	a = [*map(int, input().split())]
	b = ['0'] * n
	cnt = 0
	for i in range(n):
		if cnt < q and a[-i - 1] > cnt:
			cnt += 1
			b[-i - 1] = '1'
		elif a[-i - 1] <= cnt:
			b[-i - 1] = '1'
	print(''.join(b))


import sys
import math
from collections import Counter
from decimal import *
alfabet = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7, 'h': 8, 'i': 9, 'j': 10, 'k': 11, 'l': 12, 'm': 13, 'n': 14, 'o': 15, 'p': 16, 'q': 17, 'r': 18, 's': 19, 't': 20, 'u': 21, 'v': 22, 'w': 23, 'x': 24, 'y': 25, 'z': 26}
alfabet_2 = {'1': 'a', '2': 'b', '3': 'c', '4': 'd', '5': 'e', '6': 'f', '7': 'g', '8': 'h', '9': 'i', '10': 'j', '11': 'k', '12': 'l', '13': 'm', '14': 'n', '15': 'o', '16': 'p', '17': 'q', '18': 'r', '19': 's', '20': 't', '21': 'u', '22': 'v', '23': 'w', '24': 'x', '25': 'y', '26': 'z'}
z = int(input())
for contorr in range(z):
	(n, q) = list(map(int, input().split()))
	bloc = list(map(int, input().split()))
	elo = 0
	string = ''
	for i in range(n - 1, -1, -1):
		if bloc[i] > elo:
			if elo < q:
				elo += 1
				string += '1'
			else:
				string += '0'
		else:
			string += '1'
	print(string[::-1])


for t in range(int(input())):
	(n, q) = map(int, input().split())
	a = list(map(int, input().split()))
	a.reverse()
	Q = 0
	ans = ''
	for i in range(n):
		if a[i] <= Q:
			ans += '1'
		elif a[i] > Q and Q < q:
			Q += 1
			ans += '1'
		else:
			ans += '0'
	ans = ans[::-1]
	print(ans)


for _ in range(int(input())):
	(n, q) = map(int, input().split())
	l = list(map(int, input().split()))
	ans = ''
	x = 0
	for i in l[::-1]:
		if i <= x:
			ans += '1'
		elif x < q:
			x += 1
			ans += '1'
		else:
			ans += '0'
	print(ans[::-1])


for __ in range(int(input())):
	(n, q) = map(int, input().split())
	a = list(map(int, input().split()))
	q1 = 0
	ans = ''
	for i in range(n - 1, -1, -1):
		if q1 < a[i]:
			if q1 < q:
				q1 += 1
				ans += '1'
			else:
				ans += '0'
		else:
			ans += '1'
	print(ans[::-1])


t = int(input())
for _ in range(t):
	(n, q) = map(int, input().split())
	a = list(map(int, input().split()))
	b = ['0'] * n
	l_q = 0
	for i in range(n):
		a_i = a[-i - 1]
		if l_q < q and a_i > l_q:
			l_q += 1
			b[-i - 1] = '1'
		elif a_i <= l_q:
			b[-i - 1] = '1'
	print(''.join(b))


from collections import Counter, defaultdict, deque, namedtuple
from functools import lru_cache
from typing import List, Dict
import bisect as b
import heapq as h
import math as m

def inti():
	return int(input())

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

def main_tc():
	(n, q) = ints()
	numbers = ints()
	numbers = numbers[::-1]
	level = 0
	take = []
	for num in numbers:
		if num <= level:
			take.append('1')
		elif level < q:
			take.append('1')
			level += 1
		else:
			take.append('0')
	take = take[::-1]
	answer = ''.join(take)
	print(answer)

def main():
	tc = inti()
	for _ in range(tc):
		main_tc()
main()


import sys
import math
T = int(sys.stdin.readline())

def can_take_all(Q, A):
	if Q >= len(A):
		return True
	for a in A:
		if Q == 0:
			return False
		if a > Q:
			Q -= 1
	return True

def find_suffix(Q, A):
	if can_take_all(Q, A):
		return 0
	begin = 0
	end = len(A) - 1
	while begin < end - 1:
		mid = (begin + end) // 2
		if can_take_all(Q, A[mid:]):
			end = mid
		else:
			begin = mid
	return end

def solve(N, Q, A):
	end = find_suffix(Q, A)
	Ans = ''
	for a in A[:end]:
		if a <= Q:
			Ans += '1'
		else:
			Ans += '0'
	Ans += '1' * (N - end)
	return Ans
for _ in range(T):
	(N, Q) = list(map(int, sys.stdin.readline().split()))
	A = list(map(int, sys.stdin.readline().split()))
	print(solve(N, Q, A))


for _ in range(int(input())):
	(n, q) = list(map(int, input().split()))
	a = [*map(int, input().split())][::-1]
	lv = 0
	z = ''
	for i in range(n):
		if a[i] > lv and lv < q:
			z += '1'
			lv += 1
		elif a[i] <= q:
			z += '1'
		else:
			z += '0'
	print(z[::-1])


import sys
import math

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

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

def main():
	for _ in range(int(input())):
		(n, q) = get_ints()
		ans = [0] * n
		ls = get_ls()
		m = 0
		for i in range(n - 1, -1, -1):
			if ls[i] <= m:
				ans[i] = 1
			elif m < q:
				ans[i] = 1
				m += 1
		for c in ans:
			print(c, end='')
		print()
main()


for _ in range(int(input())):
	(n, q) = map(int, input().split())
	l = list(map(int, input().split()))
	ans = []
	q_ = 0
	for i in range(1, n + 1):
		if l[-i] > q_:
			if q_ < q:
				q_ += 1
				ans.append('1')
			else:
				ans.append('0')
		else:
			ans.append('1')
	ans.reverse()
	fa = ''
	for i in ans:
		fa += i
	print(fa)


test = int(input())

def giveSolution(array, n, q):
	minQ = [0 for i in range(n)]
	minQ[n - 1] = 1
	for i in range(n - 2, -1, -1):
		if array[i] <= minQ[i + 1]:
			minQ[i] = minQ[i + 1]
		else:
			minQ[i] = 1 + minQ[i + 1]
	result = []
	iq = q
	for i in range(n):
		if array[i] <= iq:
			result.append('1')
		elif minQ[i] <= iq:
			result.append('1')
			iq -= 1
		else:
			result.append('0')
	return ''.join(result)
for i in range(test):
	[n, q] = list(map(int, input().split()))
	array = list(map(int, input().split()))
	print(giveSolution(array, n, q))


t = int(input())

def solve():
	(n, q) = map(int, input().split())
	lst = list(map(int, input().split()))
	q1 = 0
	b = [0 for i in range(n)]
	for i in range(n - 1, -1, -1):
		if lst[i] <= q1:
			b[i] = 1
		elif q1 < q:
			b[i] = 1
			q1 += 1
	print(''.join((str(ele) for ele in b)))
while t:
	solve()
	t -= 1


for _ in range(int(input())):
	(n, q) = map(int, input().split())
	a = list(map(int, input().split()))
	s = str()
	n1 = 0
	for i in range(n - 1, -1, -1):
		if a[i] <= n1:
			s += '1'
		elif a[i] > n1 and n1 < q:
			s += '1'
			n1 += 1
		elif a[i] > n1 and n1 == q:
			s += '0'
	print(s[::-1])


t = int(input())
for _ in range(t):
	(n, q) = list(map(int, input().split(' ')))
	contests = list(map(int, input().split(' ')))
	cur_iq = 0
	ans = []
	for contest in contests[::-1]:
		if contest <= cur_iq:
			ans.append(1)
		elif cur_iq < q:
			ans.append(1)
			cur_iq += 1
		else:
			ans.append(0)
	print(''.join([str(i) for i in ans[::-1]]))


t = int(input())
for i in range(t):
	(n, q) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	nowq = 0
	ans = ['0' for _ in range(n)]
	for i in range(n - 1, -1, -1):
		if a[i] > nowq and nowq < q:
			nowq += 1
			ans[i] = '1'
		elif a[i] <= nowq:
			ans[i] = '1'
	print(''.join(ans))


T = int(input())
for tc in range(T):
	(n, q) = map(int, input().split())
	d = list(map(int, input().split()))
	s = ['0'] * n
	count = 0
	for i in range(n - 1, -1, -1):
		if d[i] <= count:
			s[i] = str(1)
		elif q > count:
			count += 1
			s[i] = str(1)
	res = ''.join(s)
	print(res)


def dermy(n, q, a):
	q1 = 0
	ans = [''] * n
	for i in range(n - 1, -1, -1):
		if a[i] <= q1:
			ans[i] += '1'
		elif q1 < q:
			q1 += 1
			ans[i] += '1'
		else:
			ans[i] += '0'
	print(''.join(ans))
for i in range(int(input())):
	(n, q) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	dermy(n, q, a)


def inp():
	return int(input())

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

def jn(x, l):
	return x.join(map(str, l))

def strl():
	return list(input().strip())

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

def mulf():
	return map(float, input().strip().split())

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

def ceil(x):
	return int(x) if x == int(x) else int(x) + 1

def ceildiv(x, d):
	return x // d if x % d == 0 else x // d + 1
for i in range(inp()):
	(n, q) = mul()
	lst = seq()
	nq = 0
	fin = ['0' for i in range(n)]
	for i in range(n):
		if lst[n - i - 1] > nq:
			if nq + 1 <= q:
				nq += 1
			else:
				continue
			fin[n - i - 1] = '1'
		else:
			fin[n - i - 1] = '1'
	print(''.join(fin))


t = int(input())
for _ in range(t):
	(n, q) = map(int, input().split())
	arr = list(map(int, input().split()))
	ans = ' '
	count = 0
	for i in arr[::-1]:
		if i <= count:
			ans += '1'
		elif count < q:
			count += 1
			ans += '1'
		else:
			ans += '0'
	x = ans[::-1]
	print(x)


t = int(input())
while t:
	(p, q) = map(int, input().split())
	s = list(map(int, input().split()))
	check = 0
	k = [0] * p
	for i in range(p - 1, -1, -1):
		if s[i] <= check:
			k[i] = 1
		elif check < q:
			check += 1
			k[i] = 1
		else:
			k[i] = 0
	print(''.join((str(i) for i in k)))
	t -= 1


for _ in range(int(input())):
	(n, q) = list(map(int, input().split(' ')))
	l = list(map(int, input().split(' ')))
	Q = 0
	b = []
	for i in range(n - 1, -1, -1):
		if l[i] <= Q:
			b.append(1)
		elif Q < q:
			b.append(1)
			Q += 1
		else:
			b.append(0)
	print(''.join((str(i) for i in b[::-1])))


for _ in range(int(input())):
	(n, q) = map(int, input().split())
	a = [*map(int, input().split())]
	(s, nq) = (0, 0)
	b = [0] * n
	for i in range(n - 1, -1, -1):
		if a[i] <= nq:
			b[i] = 1
		elif nq < q:
			nq += 1
			b[i] = 1
	print(''.join((str(x) for x in b)))


from collections import deque
N = int(input())
for _ in range(N):
	(n, q) = map(int, input().split())
	a = list(map(int, input().split()))
	cr = 0
	res = [0] * n
	for i in range(n - 1, -1, -1):
		if cr < a[i]:
			if cr < q:
				cr += 1
				res[i] = 1
			else:
				res[i] = 0
		else:
			res[i] = 1
	print(''.join(map(str, res)))


for h in range(int(input())):
	(n, q) = map(int, input().split())
	v = list(map(int, input().split()))
	if q >= n:
		print(n * '1')
	else:
		(ct, c, i) = (1, 1, n - 2)
		while i >= 0 and ct < q:
			if v[i] > ct:
				ct += 1
			c += 1
			i -= 1
		if i < 0:
			print(n * '1')
		else:
			i += 1
			for j in range(i):
				if v[j] <= q:
					print('1', end='')
				else:
					print('0', end='')
			print(c * '1')


for kk in range(int(input())):
	(n, q) = list(map(int, input().split()))
	l = list(map(int, input().split()))
	s = ['0'] * n
	curr = 0
	for i in range(n - 1, -1, -1):
		if curr < l[i]:
			if curr < q:
				curr += 1
				s[i] = '1'
			else:
				s[i] = '0'
		else:
			s[i] = '1'
	s1 = ''
	for i in s:
		s1 += i
	print(s1)


for _ in range(int(input())):
	(n, q) = map(int, input().split())
	a = list(map(int, input().split()))
	c = 0
	ans = a.copy()
	if len(a) == 1:
		print(1)
	else:
		for i in range(n - 1, -1, -1):
			if a[i] <= c:
				ans[i] = '1'
			elif a[i] > c and c < q:
				ans[i] = '1'
				c += 1
			else:
				ans[i] = '0'
		print(''.join(ans))


def computeQueries(arr, mid, q):
	for i in range(mid, len(arr)):
		if arr[i] > q:
			q -= 1
	return q

def computeGood(l, arr, q):
	s = ''
	for i in range(l + 1):
		s += '1' if arr[i] <= q else '0'
	return s

def binarySearch(arr, q):
	(l, r) = (0, len(arr) - 1)
	while l <= r:
		mid = (l + r) // 2
		query = computeQueries(arr, mid, q)
		if query < 0:
			l = mid + 1
		else:
			r = mid - 1
	return computeGood(l - 1, arr, q) + '1' * (n - l)
for _ in range(int(input())):
	(n, q) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	print(binarySearch(a, q))


def main():
	T = int(input())
	for Test in range(T):
		(n, q) = map(int, input().split())
		a = list(map(int, input().split()))
		t = 0
		ans = [0] * n
		for i in range(n - 1, -1, -1):
			if a[i] <= t:
				ans[i] = 1
			elif t < q:
				t += 1
				ans[i] = 1
		print(*ans, sep='')
main()


for _ in range(int(input())):
	(n, q) = map(int, input().strip().split())
	l = list(map(int, input().strip().split()))
	l1 = []
	c = 0
	for i in reversed(l):
		if c < i:
			if c < q:
				l1.append(1)
				c += 1
			else:
				l1.append(0)
		else:
			l1.append(1)
	for i in reversed(l1):
		print(i, end='')
	print()


t = int(input())
for _ in range(t):
	(n, q) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	arr1 = [0] * (n + 1)
	curr = 0
	for i in range(n - 1, -1, -1):
		if curr < arr[i]:
			if curr < q:
				curr += 1
				arr1[i] = 1
			else:
				arr1[i] = 0
		else:
			arr1[i] = 1
	print(*arr1[:-1], sep='')


t = int(input())
for _ in range(t):
	(n, q) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	ans = [0] * n
	ans[n - 1] = 1
	curr = 1
	for i in range(n - 2, -1, -1):
		if a[i] > curr:
			if curr < q:
				curr += 1
				ans[i] = 1
		else:
			ans[i] = 1
	for e in ans:
		print(e, end='')
	print()


for _ in range(int(input())):
	(n, q) = map(int, input().split())
	cur = 0
	arr = (0,) + tuple(map(int, input().split()))
	res = [1] * (n + 1)
	for i in range(n, 0, -1):
		if cur < arr[i]:
			if cur < q:
				cur += 1
				res[i] = 1
			else:
				res[i] = 0
		else:
			res[i] = 1
	print(*res[1:], sep='')


t = eval(input())
for _ in range(t):
	(n, q) = map(int, input().split())
	ans = list(map(int, input().split()))
	ans.reverse()
	ans1 = [0] * len(ans)
	q1 = 0
	for j in range(len(ans)):
		if q1 < ans[j]:
			if q1 == q:
				ans1[j] = 0
			else:
				ans1[j] = 1
				q1 += 1
		elif q1 >= ans[j]:
			ans1[j] = 1
	ans1.reverse()
	for i in ans1:
		print(i, end='')
	print()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = [0 for i in range(n)]
	ans = 0
	for i in range(n - 1, -1, -1):
		if ans < k:
			b[i] = 1
			if a[i] > ans:
				ans += 1
		elif a[i] <= k:
			b[i] = 1
	print(*b, sep='')


def func():
	(n, Q) = map(int, input().split())
	arr = [0]
	arr += list(map(int, input().split()))
	ans = [-1] * (n + 1)
	res = 0
	for i in range(n, 0, -1):
		if res < arr[i]:
			if res < Q:
				res += 1
				ans[i] = 1
			else:
				ans[i] = 0
		else:
			ans[i] = 1
	for i in range(1, n + 1):
		print(ans[i], end='')
	print()
tc = int(input())
while tc > 0:
	func()
	tc -= 1


out = []

def f(x, q):
	for i in range(x, n):
		if q == 0:
			return False
		if a[i] > q:
			q -= 1
	return True
for _ in range(int(input())):
	(n, q) = map(int, input().split())
	q1 = q
	a = [int(i) for i in input().split()]
	ans = ['0'] * n
	l = -1
	r = n
	while r - l > 1:
		m = (r + l) // 2
		if f(m, q):
			r = m
		else:
			l = m
	for i in range(n):
		if i < r:
			if a[i] <= q:
				ans[i] = '1'
		else:
			ans[i] = '1'
	out.append(''.join(ans))
for i in out:
	print(i)


def prnt(data):
	for i in data:
		print(i, end='')
	print()
for _ in range(int(input())):
	(n, q) = map(int, input().split())
	a = list(map(int, input().split()))
	if n <= q:
		b = [1] * n
		prnt(b)
		continue
	b = [0] * n
	for i in range(n):
		if a[i] <= q:
			b[i] = 1
	if b.count(1) == 0:
		for i in range(q):
			b[i] = 1
		prnt(b)
		continue
	qt = 0
	for j in range(n - 1, -1, -1):
		if qt < a[j]:
			qt += 1
			b[j] = 1
		if qt == q:
			break
	prnt(b)


m = lambda : map(int, input().split())
for _ in ' ' * int(input()):
	(n, q) = m()
	a = list(m())
	temp = 0
	s = []
	for i in range(n - 1, -1, -1):
		s.append(int(a[i] <= temp or q > temp))
		temp += a[i] > temp and q > temp
	print(*s[::-1], sep='')


from cmath import *
from decimal import *

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

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

def solves():
	(n, m) = _input()
	a = _list()
	ans = []
	for i in range(n):
		ans.append(0)
	i = n - 1
	cnt = 0
	while i >= 0:
		if cnt < a[i]:
			if cnt == m:
				ans[i] = 0
			else:
				ans[i] = 1
				cnt += 1
		else:
			ans[i] = 1
		i -= 1
	for i in ans:
		print(i, end='')
	print()
t = 1
t = int(input())
for _ in range(0, t):
	solves()


for _ in range(int(input())):
	(n, q) = map(int, input().split())
	l = list(map(int, input().split()))
	ans = ['0'] * n
	iq = 0
	for i in reversed(range(n)):
		if l[i] <= iq:
			ans[i] = '1'
		elif iq < q:
			ans[i] = '1'
			iq = iq + 1
		else:
			pass
	for i in range(n):
		print(ans[i], end='')
	print(' ')


for _ in range(int(input())):
	(n, q) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	ans = [0] * n
	c = 0
	if 333445 == 435454:
		print('Tanmay')
	j = 0
	mc = 0
	for i in range(n - 1, -1, -1):
		if mc == q:
			break
		if a[i] > mc:
			c += 1
			mc += 1
		ans[i] = 1
		j = i
	for i in range(j):
		if a[i] <= q:
			ans[i] = 1
	for i in ans:
		print(i, end='')
	print()


for cases in range(int(input())):
	(n, q) = map(int, input().split())
	l = list(map(int, input().split()))
	l.reverse()
	k = 0
	ls = []
	for i in range(n):
		if l[i] <= k:
			ls.append(1)
		elif k < q:
			k += 1
			ls.append(1)
		else:
			ls.append(0)
	ls.reverse()
	for i in range(n):
		print(ls[i], end='')
	print('\n', end='')


t = int(input())
for i in range(t):
	(t1, t2) = input().split()
	n = int(t1)
	q = int(t2)
	a = list(map(int, input().split()))
	Q = 0
	b = []
	for j in range(n):
		if Q >= a[n - (j + 1)]:
			b.append(1)
		elif Q < a[n - (j + 1)] and Q < q:
			b.append(1)
			Q += 1
		else:
			b.append(0)
	b.reverse()
	for j in range(n):
		print(b[j], end='')
	print()


for _ in range(int(input())):
	(n, q) = map(int, input().split())
	a = list(map(int, input().split()))
	if n <= q:
		b = [1] * n
		for i in range(n):
			print(b[i], end='')
		print()
		continue
	b = [0] * n
	for i in range(n):
		if a[i] <= q:
			b[i] = 1
	if b.count(1) == 0:
		for i in range(q):
			b[i] = 1
		for i in range(n):
			print(b[i], end='')
		print()
		continue
	qt = 0
	for _ in range(n - 1, -1, -1):
		if b[_] == 0 and qt < a[_]:
			qt = qt + 1
			b[_] = 1
		elif b[_] == 1 and qt < a[_]:
			qt = qt + 1
		if qt == q:
			break
	for i in range(n):
		print(b[i], end='')
	print()


def main():
	t = int(input())
	for _ in range(t):
		(n, q) = map(int, input().split())
		A = list(map(int, input().split()))
		l = -1
		r = n + 1
		ans = ''
		while r - l > 1:
			iq = q
			m = (l + r) // 2
			cnt = 0
			s = ''
			for i in range(m):
				if A[i] <= iq:
					s += '1'
					cnt += 1
				else:
					s += '0'
			for i in range(m, n):
				cnt += 1
				s += '1'
				if A[i] > iq:
					iq -= 1
			if iq >= 0:
				ans = s
				r = m
			else:
				l = m
		print(ans)
main()


t = int(input())
for _ in range(t):
	nums = input().split(' ')
	n = int(nums[0])
	q = int(nums[1])
	curr = 0
	ls = [int(i) for i in input().split(' ')]
	s = ''
	for i in range(n - 1, -1, -1):
		if curr < ls[i] and curr < q:
			curr += 1
			s = '1' + s
		elif curr >= ls[i]:
			s = '1' + s
		elif curr < ls[i] and curr == q:
			s = '0' + s
	print(s)


import sys

def dq(baseCases, merger):

	def solver(state):
		for (condition, resolver) in baseCases:
			if condition(state):
				return resolver(state)
		return merger(state, solver)
	return solver

def find_first_solver_builder(arr, q):

	def is_Okay(v):
		count = 0
		for i in range(v, len(arr)):
			count += int(arr[i] > q - count)
			if count > q:
				return False
		return True

	def find_first_single_step(s, f):
		(l, r) = s
		mid = l + (r - l) // 2
		return f((s[0], mid)) if is_Okay(mid) else f((mid + 1, s[1]))

	def find_first():
		return dq([(lambda s: s[0] >= s[1], lambda s: s[1])], find_first_single_step)((0, len(arr)))
	return find_first
t = int(input())
while t > 0:
	(n, q) = [int(i) for i in input().split(' ')]
	levels = [int(i) for i in input().split(' ')]
	solver = find_first_solver_builder(levels, q)
	v = solver()
	for i in range(len(levels)):
		cur = '1' if i >= v or q >= levels[i] else '0'
		print(cur, end='')
	print()
	t -= 1


def check(a, q, mid):
	ans = ''
	for i in range(len(a)):
		if i < len(a) - mid:
			if a[i] > q:
				ans += '0'
			else:
				ans += '1'
		elif a[i] > q:
			if q > 0:
				q -= 1
				ans += '1'
			else:
				return False
		else:
			ans += '1'
	return ans
for t in range(int(input())):
	(n, q) = map(int, input().split())
	a = list(map(int, input().split()))
	l = 0
	r = n
	while r - l > 1:
		mid = (l + r) // 2
		curr = check(a, q, mid)
		if curr != False:
			l = mid
		else:
			r = mid
	curr = check(a, int(q), r)
	if curr != False:
		print(curr)
	else:
		print(check(a, int(q), l))


for _ in range(int(input())):
	(n, q) = map(int, input().split())
	a = list(map(int, input().split()))
	cnt = 0
	for i in range(n):
		if a[i] <= q:
			cnt += 1

	def check(ans):
		extra = ans - cnt
		arr = [False] * n
		index = n - 1
		while index >= 0:
			if a[index] > q and extra:
				extra -= 1
				arr[index] = True
			elif a[index] <= q:
				arr[index] = True
			index -= 1
		iq = q
		for i in range(n):
			if iq == 0:
				return (False, arr)
			if arr[i] and a[i] > iq:
				iq -= 1
		return (True, arr)
	(low, high) = (cnt, n)
	ans = -1
	while low <= high:
		mid = (low + high) // 2
		t = check(mid)
		if t[0]:
			ans = t[1]
			low = mid + 1
		else:
			high = mid - 1
	print(''.join((str(int(x)) for x in ans)))


import math
for _ in range(int(input())):
	(n, q) = map(int, input().split())
	l = list(map(int, input().split()))
	low = 1
	high = n
	c = 0
	diff = 0
	s = ''
	while low <= high:
		cc = q
		mid = (low + high) // 2
		ans = 0
		ss = [0] * n
		w = mid
		kk = n
		for i in range(n):
			if l[i] > cc:
				if w >= n - i:
					if cc > 0:
						ss[i] = '1'
						w -= 1
						cc -= 1
						ans += 1
					else:
						kk = i
						break
				else:
					ss[i] = '0'
			else:
				w -= 1
				ss[i] = '1'
				ans += 1
		if ans >= mid:
			for j in range(kk, n):
				ss[j] = '0'
			s = ss.copy()
			low = mid + 1
		else:
			high = mid - 1
	print(''.join(s))