Arkady coordinates rounds on some not really famous competitive programming platform. Each round features $n$ problems of distinct difficulty, the difficulties are numbered from $1$ to $n$.

To hold a round Arkady needs $n$ new (not used previously) problems, one for each difficulty. As for now, Arkady creates all the problems himself, but unfortunately, he can't just create a problem of a desired difficulty. Instead, when he creates a problem, he evaluates its difficulty from $1$ to $n$ and puts it into the problems pool.

At each moment when Arkady can choose a set of $n$ new problems of distinct difficulties from the pool, he holds a round with these problems and removes them from the pool. Arkady always creates one problem at a time, so if he can hold a round after creating a problem, he immediately does it.

You are given a sequence of problems' difficulties in the order Arkady created them. For each problem, determine whether Arkady held the round right after creating this problem, or not. Initially the problems pool is empty.


-----Input-----

The first line contains two integers $n$ and $m$ ($1 \le n, m \le 10^5$) — the number of difficulty levels and the number of problems Arkady created.

The second line contains $m$ integers $a_1, a_2, \ldots, a_m$ ($1 \le a_i \le n$) — the problems' difficulties in the order Arkady created them.


-----Output-----

Print a line containing $m$ digits. The $i$-th digit should be $1$ if Arkady held the round after creation of the $i$-th problem, and $0$ otherwise.


-----Examples-----
Input
3 11
2 3 1 2 2 2 3 2 2 3 1

Output
00100000001

Input
4 8
4 1 3 3 2 3 3 3

Output
00001000



-----Note-----

In the first example Arkady held the round after the first three problems, because they are of distinct difficulties, and then only after the last problem.

Difficulty: EASY
Tags: Data structures

Implementation
Skill types: Data structures

Starter code:

Solutions:
from functools import reduce
s1 = input().split()
k = int(s1[0])
n = int(s1[1])
suck = list(map(int, input().split()))
maper = [0 for i in range(0, k)]
fild = 0
answer = []
for prob in suck:
	prob -= 1
	if maper[prob] == 0:
		fild += 1
	maper[prob] += 1
	if fild == k:
		maper = list(map(lambda i: i - 1, maper))
		fild = reduce(lambda res, i: res if i == 0 else res + 1, [0] + maper)
		answer.append('1')
	else:
		answer.append('0')
print(''.join(answer))


(n, m) = map(int, input().split())
tests = list(map(int, input().split()))
flag = 0
test_counters = [0] * (n + 1)
for test in tests:
	test_counters[test] += 1
	if test_counters[test] == 1:
		flag += 1
	if flag == n:
		print(1, end='')
		for j in range(1, n + 1):
			test_counters[j] -= 1
			if test_counters[j] == 0:
				flag -= 1
	else:
		print(0, end='')


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
k = 0
have = [0] * n
need = set(range(1, n + 1))
for i in range(m):
	have[a[i] - 1] += 1
	if a[i] in need:
		need.remove(a[i])
	if len(need) == 0:
		print(1, end='')
		k += 1
		for i in range(n):
			if have[i] - k == 0:
				need.add(i + 1)
	else:
		print(0, end='')


from collections import defaultdict
(n, m) = map(int, input().split())
freq = defaultdict()
l = list(map(int, input().split()))
ans = []
for i in l:
	if i not in freq:
		freq[i] = 1
	else:
		freq[i] += 1
	if len(freq) == n:
		ans.append('1')
		freq = {k: v - 1 for (k, v) in freq.items() if v > 1}
	else:
		ans.append('0')
print(''.join(ans))


s = input().split()
(n, m) = (int(s[0]), int(s[1]))
cl = list(map(int, input().split()))
st = set()
count = 1
pos = n * [0]
res = ''
for i in range(m):
	st.add(cl[i])
	pos[cl[i] - 1] += 1
	if len(st) == n:
		res += '1'
		st = set()
		count += 1
		for i in range(n):
			if pos[i] >= count:
				st.add(i + 1)
	else:
		res += '0'
print(res)


from os import path
import sys, time
from math import ceil, floor, gcd, log, log2, factorial
from collections import defaultdict, Counter, OrderedDict, deque
from itertools import combinations, groupby, zip_longest, permutations
from bisect import *
from functools import reduce
from operator import mul
maxx = float('inf')
I = lambda : int(sys.stdin.buffer.readline())
tup = lambda : map(int, sys.stdin.buffer.readline().split())
lint = lambda : [int(x) for x in sys.stdin.buffer.readline().split()]
S = lambda : sys.stdin.readline().strip('\n')
grid = lambda r: [lint() for i in range(r)]
stpr = lambda x: sys.stdout.write(f'{x}' + '\n')
star = lambda x: print(' '.join(map(str, x)))
localsys = 0
start_time = time.time()
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
(n, k) = tup()
ls = lint()
(F, d) = ([0] * n, 0)
for i in ls:
	F[i - 1] += 1
	if F[i - 1] == 1:
		d += 1
	if d == n:
		print(1, end='')
		for j in range(n):
			F[j] -= 1
			if F[j] == 0:
				d -= 1
	else:
		print(0, end='')
if localsys:
	print('\n\nTime Elased :', time.time() - start_time, 'seconds')


(n, m) = list(map(int, input().split()))
arr = list(map(int, input().split()))
vis = [0] * n
count = 0
for x in arr:
	x -= 1
	if vis[x] == 0:
		count += 1
	vis[x] += 1
	if count == n:
		print(1, end='')
		count = 0
		for i in range(n):
			vis[i] -= 1
			if vis[i] != 0:
				count += 1
	else:
		print(0, end='')
print()


def main():
	buf = input()
	buflist = buf.split()
	n = int(buflist[0])
	m = int(buflist[1])
	buf = input()
	buflist = buf.split()
	a = list(map(int, buflist))
	answer = ''
	pool = {}
	table = set()
	for i in range(n):
		table.add(i + 1)
	for i in range(m):
		if a[i] in pool:
			pool[a[i]] += 1
		else:
			pool.update({a[i]: 1})
			table.remove(a[i])
		if len(table) == 0:
			answer += '1'
			for j in range(n):
				pool[j + 1] -= 1
				if pool[j + 1] <= 0:
					pool.pop(j + 1)
					table.add(j + 1)
		else:
			answer += '0'
	print(answer)
main()


(k, n) = input().split()
l = [int(i) for i in input().split()]
d = {i: 0 for i in l}
single = set()
repeat = set()
ans = ''
for i in l:
	if d[i] == 0:
		single.add(i)
		d[i] += 1
	else:
		if i in single:
			single.remove(i)
		repeat.add(i)
		d[i] += 1
	if len(single) + len(repeat) == int(k):
		for m in single:
			d[m] = 0
		single = set()
		temp = []
		for j in repeat:
			d[j] -= 1
			if d[j] == 0:
				temp.append(j)
		for j in temp:
			repeat.remove(j)
		ans += '1'
	else:
		ans += '0'
print(ans)


def main():
	(n, m) = [int(x) for x in input().split(' ')]
	a = [int(x) for x in input().split(' ')]
	order = [0 for i in range(n + 1)]
	used = [0 for i in range(m + 1)]
	times = []
	for (i, val) in enumerate(a):
		order[val] += 1
		used[order[val]] += 1
		if used[order[val]] == n:
			times.append('1')
		else:
			times.append('0')
	print(''.join(times))
main()


(n, m) = map(int, input().split())
tasks = list(map(int, input().split()))
bank = [0] * n
zeros = n
res = []
for t in tasks:
	if bank[t - 1] == 0:
		zeros -= 1
	bank[t - 1] += 1
	if zeros == 0:
		for i in range(n):
			bank[i] -= 1
			if bank[i] == 0:
				zeros += 1
		res.append(1)
	else:
		res.append(0)
print(*res, sep='')


(a, b) = map(int, input().split())
m = list(map(int, input().split()))
s = set()
c = {}
co = ''
for i in m:
	if i not in s:
		s.add(i)
	elif i in c:
		c[i] += 1
	else:
		c[i] = 1
	if len(s) == a:
		co += '1'
		s.clear()
		for i in c:
			s.add(i)
			c[i] -= 1
		for i in s:
			if c[i] == 0:
				del c[i]
	else:
		co += '0'
print(co)


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
q = [0 for i in range(n)]
need = 0
for i in range(m):
	a = arr[i]
	a -= 1
	if q[a] == 0:
		need += 1
	q[a] += 1
	if need == n:
		print(1, end='')
		for j in range(n):
			q[j] -= 1
			if q[j] == 0:
				need -= 1
	else:
		print(0, end='')


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = [0 for i in range(n)]
ans = ''
dic = {}
while len(a) > 0:
	c = a.pop(0)
	if c in dic:
		dic[c] += 1
	else:
		dic[c] = 0
	if len(dic) == n:
		ans += '1'
		for i in range(n):
			if dic[i + 1] == 0:
				dic.pop(i + 1)
			else:
				dic[i + 1] -= 1
	else:
		ans += '0'
print(ans)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
dist = 0
freq = [0] * n
for i in range(m):
	if freq[l[i] - 1] == 0:
		dist += 1
	freq[l[i] - 1] += 1
	if dist == n:
		print('1', end='')
		for j in range(n):
			freq[j] -= 1
			if freq[j] == 0:
				dist -= 1
	else:
		print('0', end='')


(n, m) = map(int, input().split())
b = list(map(int, input().split()))
v = [[] for j in range(n + 1)]
for j in range(m):
	v[b[j]].append(j)
a = ['0'] * m
j = 1
p = 10 ** 6
while j <= n:
	p = min(p, len(v[j]))
	j += 1
j = 0
while j < p:
	m = -1
	for i in range(1, n + 1):
		m = max(m, v[i][j])
	a[m] = '1'
	j += 1
print(''.join(a))


def funcao(lista, res, n):
	conj = set()
	mapa = {}
	i = 0
	while i < len(lista):
		conj.add(lista[i])
		if lista[i] in mapa:
			mapa[lista[i]] += 1
		else:
			mapa[lista[i]] = 1
		if len(conj) == n:
			for e in mapa.keys():
				mapa[e] -= 1
				if mapa[e] == 0:
					conj.remove(e)
			res[i] = '1'
		i += 1
entrada = input().split()
n = int(entrada[0])
m = int(entrada[1])
res = ['0'] * m
lista = input().split()
funcao(lista, res, n)
print(''.join(res))


(n, k) = map(int, input().split())
diff = list(map(int, input().split()))
contest = 0
d = {}
for i in diff:
	try:
		d[i] += 1
	except:
		d[i] = 1
	if len(d) == n:
		for j in range(1, n + 1):
			d[j] -= 1
			if d[j] == 0:
				del d[j]
		print('1', end='')
	else:
		print('0', end='')


(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
rec = [0] * n
dic = {}
for i in range(m):
	rec[a[i] - 1] += 1
	dic[rec[a[i] - 1]] = i
t = ['0'] * m
mi = min(rec)
for i in range(1, mi + 1):
	t[dic[i]] = '1'
print(''.join(map(str, t)))


(n, m) = [int(x) for x in input().split(' ')]
a = [int(x) for x in input().split(' ')]
a_dict = {}
ans = ''
for p in a:
	if p in a_dict.keys():
		a_dict[p] += 1
	else:
		a_dict[p] = 1
	if len(a_dict) == n:
		ans += '1'
		for k in a_dict.keys():
			a_dict[k] -= 1
		a_dict = {k: a_dict[k] for k in a_dict.keys() if a_dict[k]}
	else:
		ans += '0'
print(ans)


R = lambda : map(int, input().split())
(n, m) = R()
L = list(R())
L = [i - 1 for i in L]
f = [0] * n
d = {}
for (j, i) in enumerate(L):
	f[i] += 1
	d[f[i]] = j
res = ['0'] * m
mi = min(f)
for i in range(1, mi + 1):
	res[d[i]] = '1'
print(''.join(res))


(n, k) = input().split()
n = int(n)
k = int(k)
l = list(map(int, input().split()))
ar = [0] * 100001
q = [0] * 100001
for i in l:
	ar[i] = ar[i] + 1
	q[ar[i]] = q[ar[i]] + 1
	if q[ar[i]] == n:
		print('1', end='')
	else:
		print(0, end='')


(n, m) = map(int, input().split())
a = [*map(int, input().split())]
problem = [-1] * n
ans = [0] * m
for i in range(m):
	problem[a[i] - 1] += 1
	ans[problem[a[i] - 1]] += 1
	if ans[problem[a[i] - 1]] == n:
		print(1, end='')
	else:
		print(0, end='')


def Decrease(dic, count):
	for i in dic.keys():
		dic[i][0] -= 1
		dic[i][1] = 0
		if dic[i][0] > 0:
			dic[i][1] = 1
			count += 1
	return count

def Solve(n, diff):
	dic = {}
	count = 0
	ans = ''
	for i in diff:
		if i not in dic.keys():
			dic[i] = []
			dic[i] = [1, 1]
			count += 1
		else:
			dic[i][0] += 1
			if dic[i][1] == 0:
				count += 1
				dic[i][1] = 1
		if count == n:
			ans += str(1)
			count = 0
			count = Decrease(dic, count)
		else:
			ans += str(0)
	return ans

def main():
	(n, m) = map(int, input().split())
	diff = list(map(int, input().split()))
	print(Solve(n, diff))
main()


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
x = [0] * (n + 1)
ans = [0] * (m + 1)
for i in l:
	x[i] += 1
	ans[x[i]] += 1
	if ans[x[i]] == n:
		print('1', end='')
	else:
		print('0', end='')


(n, m) = map(int, input().split())
c = [0 for i in range(n)]
num = [0 for i in range(m + 1)]
j = 1
l = [int(i) for i in input().split()]
for i in range(m):
	c[l[i] - 1] += 1
	num[c[l[i] - 1]] += 1
	if num[j] == n:
		print(1, end='')
		j += 1
	else:
		print(0, end='')


(n, m) = map(int, input().split())
arr = [0] * n
ll = 0
for i in map(int, input().split()):
	if arr[i - 1] == 0:
		ll += 1
	arr[i - 1] += 1
	if ll == n:
		for j in range(n):
			arr[j] -= 1
			if arr[j] == 0:
				ll -= 1
		print('1', end='')
	else:
		print('0', end='')


(n, m) = [int(i) for i in input().split(' ')]
lista = [int(i) - 1 for i in input().split(' ')]
asnwer = ''
acumulados = [0] * n
quantidade_de_1 = 0
reimaning = n
for entrada in lista:
	if acumulados[entrada] == quantidade_de_1:
		reimaning -= 1
	acumulados[entrada] += 1
	if reimaning == 0:
		quantidade_de_1 += 1
		quantidade_maior = 0
		for i in acumulados:
			if i > quantidade_de_1:
				quantidade_maior += 1
		reimaning = n - quantidade_maior
		asnwer += '1'
	else:
		asnwer += '0'
print(asnwer)


[n, k] = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
d = {}
s = set()
for i in a:
	s.add(i)
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
	if len(s) == n:
		print(1, end='')
		for j in d:
			d[j] -= 1
			if d[j] == 0:
				s.remove(j)
	else:
		print(0, end='')
print()


from collections import defaultdict
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
problems = defaultdict(int)
cur_sum = 0
difficulty_sum = n * (n + 1) // 2
types = set()
ans = []
for i in a:
	cur_ans = '0'
	problems[i] += 1
	if i not in types:
		types.add(i)
		cur_sum += i
		if cur_sum == difficulty_sum:
			cur_ans = '1'
			for t in range(1, n + 1):
				problems[t] -= 1
				if problems[t] == 0:
					types.remove(t)
					cur_sum -= t
	ans.append(cur_ans)
print(''.join(ans))


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

def fi():
	return float(input())

def si():
	return input()

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

def li():
	return list(mi())
(n, m) = mi()
l = li()
c = [0] * n
a = [0] * (m + 1)
j = 1
k = []
for i in range(m):
	c[l[i] - 1] += 1
	a[c[l[i] - 1]] += 1
	if a[j] == n:
		print(1, end='')
		j += 1
	else:
		print(0, end='')


from collections import Counter
(n, m) = map(int, input().split())
dic = list(map(int, input().split()))
c = Counter()
for d in dic:
	if d in c:
		c[d] += 1
	else:
		c[d] = 1
	if len(c) == n:
		for i in range(1, n + 1):
			if c[i] == 1:
				del c[i]
			else:
				c[i] -= 1
		print(1, end='')
	else:
		print(0, end='')
print()


(n, m) = map(int, input().split())
(pool, saida, qtd) = ([0] * n, list(), 0)
for problem in map(int, input().split()):
	pool[problem - 1] += 1
	if pool[problem - 1] == 1:
		qtd += 1
		if qtd == n:
			saida.append('1')
			for i in range(n):
				pool[i] -= 1
			qtd = n - pool.count(0)
			continue
	saida.append('0')
print(''.join(saida))


from collections import deque
(n, m) = [int(p) for p in input().split()]
arr = [int(p) for p in input().split()]
res = ['0'] * m
index = dict()
for i in range(1, n + 1):
	index[i] = deque()
for i in range(len(arr)):
	index[arr[i]].append(i)
currMax = 0
while True:
	for i in range(1, n + 1):
		if index[i]:
			pos = index[i].popleft()
			currMax = max(currMax, pos)
		else:
			print(''.join(res))
			exit()
	res[currMax] = '1'


from collections import deque
s = input().split()
n = int(s[0])
m = int(s[1])
a = list(map(int, input().split()))
result = ['0'] * m
d = {}
for i in range(m):
	c = None
	if a[i] in d:
		c = d[a[i]]
	else:
		c = deque()
		d[a[i]] = c
	c.append(i)
while True:
	found = True
	max_p = 0
	for i in range(1, n + 1):
		if i not in d or len(d[i]) == 0:
			found = False
			break
		p = d[i].popleft()
		if p > max_p:
			max_p = p
	if found == False:
		break
	result[max_p] = '1'
print(''.join(result))


from collections import defaultdict
(n, m) = map(int, input().split())
vec = list(map(int, input().split()))
cnt = [0] * (n + 1)
cur = 0
for v in vec:
	cnt[v] += 1
	if cnt[v] == 1:
		cur += 1
	if cur == n:
		for j in range(1, n + 1):
			cnt[j] -= 1
			if cnt[j] == 0:
				cur -= 1
		print(1, end='')
	else:
		print(0, end='')


(n, m) = map(int, input().split())
r = 0
p = [0] * n
ans = []
b = [False] * n
f = n
for i in map(lambda x: int(x) - 1, input().split()):
	bf = b[i]
	p[i] += 1
	b[i] = p[i] > r
	if not bf and b[i]:
		f -= 1
		if f == 0:
			ans.append('1')
			r += 1
			f = n
			for x in range(n):
				if p[x] > r:
					f -= 1
					b[x] = True
				else:
					b[x] = False
			continue
	ans.append('0')
print(''.join(ans))


p = 10 ** 5 + 9
from collections import defaultdict
cnt = defaultdict(int)
(n, m) = map(int, input().split())
l = [int(i) for i in input().split()]
s = ''
c = 0
f = 0
for i in range(m):
	cnt[l[i]] += 1
	if cnt[l[i]] == 1:
		c += 1
	if c == n:
		s += '1'
		for i in cnt:
			cnt[i] -= 1
			if cnt[i] == 0:
				c -= 1
	else:
		s += '0'
print(s)


def main():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	count_dict = {}
	ret = []
	for x in a:
		count_dict[x] = count_dict.get(x, 0) + 1
		if len(count_dict) == n:
			ret.append('1')
			for i in range(1, n + 1):
				count_dict[i] -= 1
				if count_dict[i] == 0:
					del count_dict[i]
		else:
			ret.append('0')
	print(''.join(ret))
main()


import math

def check(ar, s):
	if ar.count(s) > 0:
		return True
	return False
(n, m) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
cnt = [0 for i in range(100001)]
exis = [0 for i in range(100001)]
b = {}
k = 1
r = ''
for i in a:
	cnt[i] += 1
	exis[cnt[i]] += 1
	if exis[k] == n:
		r += '1'
		k += 1
	else:
		r += '0'
print(r)


(n, m) = map(int, input().split())
a = [int(x) for x in input().split()]
l1 = [0] * (n + 1)
l2 = [0] * (m + 1)
for x in a:
	l1[x] += 1
	l2[l1[x]] += 1
	if l2[l1[x]] == n:
		print('1', end='')
	else:
		print('0', end='')


(n, k) = list(map(int, input().strip().split()))
a = list(map(int, input().strip().split()))
remaining_dict = dict()
for i in range(n):
	remaining_dict[i + 1] = 1
num_elem_gr_zero = n
for elem in a:
	remaining_dict[elem] -= 1
	if remaining_dict[elem] == 0:
		num_elem_gr_zero -= 1
	if num_elem_gr_zero != 0:
		print('0', end='')
	else:
		print('1', end='')
		for i in range(n):
			remaining_dict[i + 1] += 1
			if remaining_dict[i + 1] == 1:
				num_elem_gr_zero += 1


import sys
readline = sys.stdin.readline

class Segtree:

	def __init__(self, A, intv, initialize=True, segf=max):
		self.N = len(A)
		self.N0 = 2 ** (self.N - 1).bit_length()
		self.intv = intv
		self.segf = segf
		if initialize:
			self.data = [intv] * self.N0 + A + [intv] * (self.N0 - self.N)
			for i in range(self.N0 - 1, 0, -1):
				self.data[i] = self.segf(self.data[2 * i], self.data[2 * i + 1])
		else:
			self.data = [intv] * (2 * self.N0)

	def add(self, k, x):
		k += self.N0
		self.data[k] += x
		while k > 0:
			k = k >> 1
			self.data[k] = self.segf(self.data[2 * k], self.data[2 * k + 1])

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

	def binsearch(self, l, r, check, reverse=False):
		(L, R) = (l + self.N0, r + self.N0)
		(SL, SR) = ([], [])
		while L < R:
			if R & 1:
				R -= 1
				SR.append(R)
			if L & 1:
				SL.append(L)
				L += 1
			L >>= 1
			R >>= 1
		if reverse:
			for idx in SR + SL[::-1]:
				if check(self.data[idx]):
					break
			else:
				return -1
			while idx < self.N0:
				if check(self.data[2 * idx + 1]):
					idx = 2 * idx + 1
				else:
					idx = 2 * idx
			return idx - self.N0
		else:
			for idx in SL + SR[::-1]:
				if check(self.data[idx]):
					break
			else:
				return -1
			while idx < self.N0:
				if check(self.data[2 * idx]):
					idx = 2 * idx
				else:
					idx = 2 * idx + 1
			return idx - self.N0
(N, M) = map(int, readline().split())
Ans = [0] * M
A = list(map(lambda x: int(x) - 1, readline().split()))
inf = 10 ** 9 + 7
T = Segtree([0] * N, inf, initialize=True, segf=min)
cm = 0
N0 = T.N0
for i in range(M):
	a = A[i]
	T.add(a, 1)
	if cm < T.query(0, N):
		Ans[i] = 1
		cm += 1
print(''.join(map(str, Ans)))


def get_int_list():
	from sys import stdin
	return [int(x) for x in stdin.readline().replace('\n', '').split(' ')]

def get_levels(stand_by, n):
	levels = {x for x in range(1, n + 1)}
	for l in stand_by:
		if l in levels and stand_by[l] > 0:
			levels.remove(l)
			stand_by[l] -= 1
	return levels

def hold_a_round(n, difficulties):
	levels = {x for x in range(1, n + 1)}
	result = ''
	stand_by = {}
	for d in difficulties:
		if d in levels:
			levels.remove(d)
		else:
			stand_by[d] = 1 if d not in stand_by else stand_by[d] + 1
		if len(levels) == 0:
			result += '1'
			levels = get_levels(stand_by, n)
		else:
			result += '0'
	return result
(n, m) = get_int_list()
difficulties = get_int_list()
print(hold_a_round(n, difficulties))


def buildContest(problems, m):
	prob_map = {}
	output = ''
	found = set()
	for prob in problems:
		prob_map[prob] = prob_map.get(prob, 0) + 1
		found.add(prob)
		if len(found) == m:
			output += '1'
			for p in prob_map:
				prob_map[p] -= 1
				if prob_map[p] == 0:
					found.remove(p)
		else:
			output += '0'
	return output
(n, m) = input().split()
problems = list(map(int, input().split()))
print(buildContest(problems, int(n)))


(N, M) = map(int, input().split())
aM = list(map(int, input().split()))
level = [0] * (N + 1)
cnt = 0
ans = ['0'] * M
for i in range(M):
	if level[aM[i]] == 0:
		cnt += 1
	level[aM[i]] += 1
	if cnt == N:
		ans[i] = '1'
		for j in range(1, N + 1):
			level[j] -= 1
			if level[j] == 0:
				cnt -= 1
print(''.join(ans))


(num_de_niveis, num_de_problemas) = map(int, input().split())
dificuldades = list(map(int, input().split()))
conjunto = set()
dicionario = {}
digitos = ''
for i in range(num_de_problemas):
	if dificuldades[i] in dicionario:
		dicionario[dificuldades[i]] += 1
	else:
		dicionario[dificuldades[i]] = 1
	if len(dicionario) == num_de_niveis:
		digitos += '1'
		for j in range(1, num_de_niveis + 1):
			dicionario[j] -= 1
			if dicionario[j] == 0:
				del dicionario[j]
	else:
		digitos += '0'
print(digitos)


(n, m) = (int(x) for x in input().split())
a = [int(x) for x in input().split()]
d = {}
for ai in a:
	d.setdefault(ai, 0)
	d[ai] += 1
	ans = 0
	if len(d) >= n:
		ans = 1
		d = {k: v - 1 for (k, v) in d.items() if v > 1}
	print(ans, end='')


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
cnt = [0] * (n + 1)
dct = [0] * 100001
dct[0] = n
dscrtcnt = 0
num = 0
for i in l:
	flag = '0'
	cnt[i] += 1
	dct[cnt[i]] += 1
	dct[cnt[i] - 1] -= 1
	if cnt[i] == num + 1:
		dscrtcnt += 1
		if dscrtcnt == n:
			flag = '1'
			dscrtcnt -= dct[num + 1]
			num += 1
	print(flag, end='')


(n, m) = [int(s) for s in input().split()]
a = [int(s) for s in input().split()]
more = dict(zip([s for s in range(1, n + 1)], [0 for s in range(n)]))
round = set()
ans = ''
for i in range(m):
	more[a[i]] = more[a[i]] + 1
	round.add(a[i])
	if len(round) == n:
		ans += '1'
		round = set()
		for key in more:
			more[key] -= 1
			if more[key] > 0:
				round.add(key)
	else:
		ans += '0'
print(ans)


(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
cnt = [0] * n
cur_bank = set()
ver = 1
ans = list()
for i in range(m):
	a[i] -= 1
	cnt[a[i]] += 1
	cur_bank.add(a[i])
	if len(cur_bank) == n:
		cur_bank = set()
		for j in range(len(cnt)):
			cnt[j] -= 1
			if cnt[j] > 0:
				cur_bank.add(j)
		ans.append('1')
	else:
		ans.append('0')
print(''.join(ans))


(n, m) = map(int, input().split())
a = [int(x) for x in input().split()]
d = {}
for x in a:
	if not d.get(x):
		d[x] = 1
	else:
		d[x] += 1
	if len(d) == n:
		print('1', end='')
		for k in list(d.keys()):
			d[k] -= 1
			if d[k] == 0:
				del d[k]
	else:
		print('0', end='')


I = lambda : map(int, input().split())
(n, m) = I()
ms = list(I())
contest = 0
output = ''
nums = [0] * (n + 1)
for value in ms:
	if nums[value] == 0:
		contest += 1
	nums[value] += 1
	if contest == n:
		output += '1'
		contest = 0
		for j in range(1, len(nums)):
			nums[j] -= 1
			if nums[j] > 0:
				contest += 1
	else:
		output += '0'
print(output)


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
ans = ''
count = [0] * (n + 1)
val2 = 0
contests = 1
problems = [0] * (m + 1)
for i in range(m):
	count[arr[i]] += 1
	problems[count[arr[i]]] += 1
	if problems[contests] == n:
		ans += '1'
		contests += 1
	else:
		ans += '0'
print(ans)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
x = ''
g = [0] * (n + 1)
v = [0] * (m + 1)
k = 0
for i in range(m):
	g[l[i]] += 1
	v[g[l[i]] - 1] += 1
	if v[k] == n:
		k += 1
		x += '1'
	else:
		x += '0'
print(x)


def chPathToThis(f=None):
	import os
	f = __file__ if f is None else f
	os.chdir(os.path.dirname(f))
fle = None

def input():
	global fle

	def inner():
		if fle is None:
			from sys import stdin
			for line in stdin:
				yield line
			raise EOFError
		else:
			for line in fle:
				yield line.replace('\r', '').replace('\n', '')
			raise EOFError
	o = inner()
	return next(o)

def main():
	(n, m) = map(int, input().split())
	a = [int(e) for e in input().split()]
	(b, c) = ([0] * (n + 4), [0] * (m + 4))
	for i in a:
		b[i] += 1
		c[b[i]] += 1
		print('1' if c[b[i]] >= n else '0', end='')
try:
	import time, numpy
	chPathToThis(__file__)
	(begin, fle) = (time.clock(), open('pytest.txt'))
	main()
	fle.close()
	print(time.clock() - begin)
except ImportError:
	main()


(n, k) = [int(x) for x in input().split()]
z = [int(x) for x in input().split()]
bank = [0] * n
ban = 0
tot = []
for item in z:
	if bank[item - 1] == 0:
		ban += 1
	bank[item - 1] += 1
	if ban == n:
		tot.append(1)
		ban = 0
		for i in range(len(bank)):
			bank[i] -= 1
			if bank[i] >= 1:
				ban += 1
	else:
		tot.append(0)
total = ''
for item in tot:
	total += str(item)
print(total)


(n, m) = map(int, input().split())
s = list(map(int, input().split()))
dic = dict()
d = dict()
k = 0
for i in s:
	dic[i] = dic.get(i, 0) + 1
	d[dic[i]] = d.get(dic[i], 0) + 1
	if d[k + 1] == n:
		k += 1
		print('1', end='')
	else:
		print('0', end='')


(n, m) = map(int, input().split())
tm = m // n
a = [[-1 for _ in range(n)] for _ in range(tm)]
ans = ['0'] * m
b = [0] * n
if tm == 0:
	print(''.join(ans))
else:
	i = 0
	for el in map(int, input().split()):
		j = min(b[el - 1], tm - 1)
		if a[j][el - 1] == -1:
			a[j][el - 1] = i
		i += 1
		b[el - 1] += 1
	k = min(b)
	for i in range(k):
		ans[max(a[i])] = '1'
	print(''.join(ans))


from collections import defaultdict as dc
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
cnt = 0
m = dc(int)
sm = dc(int)
for i in range(k):
	sm[m[a[i]]] += 1
	m[a[i]] += 1
	if sm[cnt] == n:
		cnt += 1
		print(1, end='')
	else:
		print(0, end='')


from sys import stdin, stdout
input = stdin.readline
print = stdout.write
listin = lambda : list(map(int, input().split()))
mapin = lambda : map(int, input().split())
(n, m) = mapin()
a = listin()
d = {}
z = set(a)
s = set([])
for i in range(1, n + 1):
	if i in z:
		continue
	else:
		print('0' * m + '\n')
		exit()
for i in a:
	d.setdefault(i, 0)
for i in a:
	d[i] += 1
	s.add(i)
	if len(s) == n:
		print('1')
		for j in d:
			d[j] -= 1
			if d[j] == 0:
				s.remove(j)
	else:
		print('0')
print('\n')


[n, m] = [int(i) for i in input().split()]
gs = [int(i) - 1 for i in input().split()]
ngs = [0] * n
empty_games = n
out = ''
for i in range(m):
	g = gs[i]
	if ngs[g] == 0:
		empty_games -= 1
	ngs[g] += 1
	if empty_games == 0:
		for j in range(n):
			ngs[j] -= 1
			if ngs[j] == 0:
				empty_games += 1
		out += '1'
	else:
		out += '0'
print(out)


(n, m) = list(map(int, input().split()))
reach = [0] * 100001
current = 1
count = [0] * 100001
a = list(map(int, input().split()))
ans = []
for i in a:
	count[i] += 1
	reach[count[i]] += 1
	if current == count[i] and reach[count[i]] == n:
		ans.append('1')
		current += 1
	else:
		ans.append('0')
print(''.join(ans))


def B():
	(n, m) = map(int, input().split())
	counter = {i: 0 for i in range(1, n + 1)}
	inp = [int(x) for x in input().split()]
	ans = ''
	colours = n
	for i in inp:
		if counter[i] == 0:
			colours -= 1
		counter[i] += 1
		if not colours:
			ans += '1'
			for i in range(1, n + 1):
				counter[i] -= 1
				if not counter[i]:
					colours += 1
		else:
			ans += '0'
	print(ans)
B()


(n, m) = map(int, input().split())
mas = list(map(int, input().split()))
pol = [0] * n
null = 0
ans = ''
for i in range(m):
	pol[mas[i] - 1] += 1
	if pol[mas[i] - 1] == 1:
		null += 1
	if null == n:
		ans += '1'
		null = 0
		for j in range(n):
			pol[j] -= 1
			if pol[j] != 0:
				null += 1
	else:
		ans += '0'
print(ans)


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97

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

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

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

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

def revn(n):
	return str(n)[::-1]

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

def ddl():
	return collections.defaultdict(list)

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):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

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 prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)
(n, m) = mi()
arr = li()
c = [0] * n
e = [0] * m
ans = ''
k = 0
for i in range(m):
	c[arr[i] - 1] += 1
	e[c[arr[i] - 1] - 1] += 1
	if e[k] == n:
		ans += '1'
		k += 1
	else:
		ans += '0'
print(ans)


import math
sa = lambda : input()
sb = lambda : int(input())
sc = lambda : input().split()
sd = lambda : list(map(int, input().split()))
se = lambda : float(input())
sf = lambda : list(input())

def hnbhai():
	(n, m) = sd()
	a = sd()
	b = [0] * (n + 1)
	ans = [0] * (m + 1)
	for i in a:
		b[i] += 1
		ans[b[i]] += 1
		if ans[b[i]] == n:
			print('1', end='')
		else:
			print('0', end='')
	print()
for _ in range(1):
	hnbhai()


l = input().split()
(k, n) = (int(l[0]), int(l[1]))
arr = list(map(int, input().split()))
counts = [0 for i in range(k)]
s = set()
ans = []
for x in arr:
	counts[x - 1] += 1
	s.add(x - 1)
	if len(s) == k:
		ans.append(1)
		for j in range(k):
			counts[j] -= 1
			if counts[j] == 0:
				s.remove(j)
	else:
		ans.append(0)
print(''.join(list(map(str, ans))))


(k, n) = [int(x) for x in input().split()]
(pointers, indices) = ([], [])
problems = [[int(x)] for x in input().split()]
for i in range(n):
	problems[i].append(i)
problems.sort()
(prev, all_zeros) = (0, False)
for i in range(n):
	if problems[i][0] > prev + 1:
		all_zeros = True
		break
	if problems[i][0] > prev:
		pointers.append(i)
		prev = problems[i][0]
if all_zeros or len(pointers) != k:
	print('0' * n)
else:
	(increment, out_of_bound) = (0, False)
	while pointers[-1] + increment < n and (not out_of_bound):
		(out_of_bound, max_index) = (False, problems[increment][1])
		for i in range(1, k):
			if not problems[pointers[i] + increment][0] == problems[pointers[i - 1] + increment][0] + 1:
				out_of_bound = True
				break
			max_index = max(max_index, problems[pointers[i] + increment][1])
		if not out_of_bound:
			indices.append(max_index)
		increment += 1
	index = 0
	for i in range(n):
		if index < len(indices) and indices[index] == i:
			print('1', end='')
			index += 1
		else:
			print('0', end='')


[n, m] = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
nums = {}
output = []
num_equal = [0] * 100100
count = [0] * 100100
for d in a:
	count[d] += 1
	num_equal[count[d]] += 1
	if num_equal[count[d]] == n:
		output.append(1)
	else:
		output.append(0)
print(''.join([str(x) for x in output]))


from collections import Counter
import math
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
a = [0] * 100001
s = '0'
r = [0] * (n + 1)
i = 0
k = 1
while i < m:
	r[l[i]] += 1
	a[r[l[i]]] += 1
	if a[r[l[i]]] == n:
		s = s + '1'
	else:
		s = s + '0'
	i += 1
print(s[1:])


from sys import *
from math import *
from bisect import *
(n, k) = map(int, stdin.readline().split())
a = list(map(int, stdin.readline().split()))
x = [0] * n
d = [0] * k
s = 0
for i in range(k):
	if x[a[i] - 1] == 0:
		s += 1
	x[a[i] - 1] += 1
	if s == n:
		d[i] = 1
		s = 0
		for j in range(n):
			x[j] -= 1
			if x[j] > 0:
				s += 1
print(*d, sep='')


(n, m) = [int(i) for i in input().split()]
ar = [int(i) for i in input().split()]
ans = [0] * m
was = [0] * (n + 1)
r = 0
d = 0
for i in range(m):
	x = ar[i]
	was[x] += 1
	if was[x] == 1:
		r += 1
	if r == n:
		ans[i] = 1
		r = 0
		for j in range(1, n + 1):
			was[j] -= 1
			if was[j] > 0:
				r += 1
	else:
		ans[i] = 0
print(''.join((str(i) for i in ans)))


def main():
	(n, qtd) = map(int, input().split())
	output = ''
	niveis_necessarios = n
	contadores = {}
	for i in range(1, n + 1):
		contadores[str(i)] = 0
	for nivel in input().split():
		contadores[nivel] += 1
		if contadores[nivel] == 1:
			niveis_necessarios -= 1
		if niveis_necessarios == 0:
			for k in contadores:
				contadores[k] -= 1
				if contadores[k] == 0:
					niveis_necessarios += 1
			output += '1'
		else:
			output += '0'
	print(output)
main()


entrada = list(map(int, input().split()))
mapa = {}
saida = ''
lista = list(map(int, input().split()))
for i in range(entrada[1]):
	x = lista[i]
	if x in mapa:
		mapa[x] += 1
	else:
		mapa[x] = 1
	if len(mapa) == entrada[0]:
		saida += '1'
		for j in range(1, entrada[0] + 1):
			mapa[j] = mapa[j] - 1
			if mapa[j] == 0:
				del mapa[j]
	else:
		saida += '0'
print(saida)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = [0] * (n + 5)
c = [0] * (m + 5)
c[0] = n
cur = 0
for i in range(m):
	c[b[a[i]]] -= 1
	b[a[i]] += 1
	c[b[a[i]]] += 1
	if c[cur] == 0:
		print(1, end='')
		cur += 1
	else:
		print(0, end='')


import collections
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
d = collections.defaultdict(int)
(c, t, k) = (0, 1, 1)
v = collections.defaultdict(int)
for i in range(m):
	d[a[i]] += 1
	v[d[a[i]]] += 1
	if v[k] == n:
		print(1, end='')
		k += 1
	else:
		print(0, end='')


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
l1 = {}
s = ''
k = 0
l2 = set()
for x in l:
	l1[x] = l1.get(x, 0) + 1
	if l1[x] == 1:
		k += 1
		l2.add(x)
	if k != n:
		s += '0'
	else:
		lf = []
		for x1 in l2:
			l1[x1] -= 1
			if l1[x1] == 0:
				k -= 1
				lf.append(x1)
		for x1 in lf:
			l2.remove(x1)
		s += '1'
print(s)


(n, m) = map(int, input().split())
d = dict()
ans = []
for c in input().split():
	if c not in d.keys():
		d[c] = 1
		if len(d) < n:
			ans.append('0')
		else:
			ans.append('1')
			dk = list(d.keys())
			for k in dk:
				d[k] -= 1
				if d[k] == 0:
					d.pop(k)
	else:
		d[c] += 1
		ans.append('0')
print(''.join(ans))


list_int_input = lambda inp: list(map(int, inp.split()))
int_input = lambda inp: int(inp)
string_to_list_input = lambda inp: list(inp)
nm = list_int_input(input())
(n, m) = (nm[0], nm[1])
a = list_int_input(input())
s = ''
cnt = [0 for i in range(n + 1)]
scnt = 0
for i in a:
	if cnt[i] == 0:
		scnt += 1
	cnt[i] += 1
	if scnt == n:
		s += '1'
		for j in range(1, n + 1):
			cnt[j] -= 1
			if cnt[j] == 0:
				scnt -= 1
	else:
		s += '0'
print(s)


import sys
input = sys.stdin.readline
f = lambda : list(map(int, input().split()))
(n, m) = f()
cnt = [0] * (n + 1)
num = [0] * (m + 1)
ans = [0] * m
for (i, v) in enumerate(f()):
	cnt[v] += 1
	num[cnt[v]] += 1
	ans[i] = 1 if num[cnt[v]] == n else 0
print(''.join(map(str, ans)))


from collections import Counter
(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
s = set()
unused = Counter()
ans = []
for i in range(m):
	if arr[i] not in s:
		s.add(arr[i])
	elif arr[i] in unused:
		unused[arr[i]] += 1
	else:
		unused[arr[i]] = 1
	if len(s) == n:
		s = set()
		for x in unused.keys():
			unused[x] -= 1
			s.add(x)
		for x in s:
			if unused[x] == 0:
				del unused[x]
		ans.append('1')
	else:
		ans.append('0')
print(''.join(ans))


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
c = 0
arr = [0] * (n + 1)
for i in range(m):
	if arr[x[i]] == 0:
		c += 1
	arr[x[i]] += 1
	if c == n:
		print('1', end='')
		for k in range(1, n + 1):
			arr[k] -= 1
			if arr[k] == 0:
				c -= 1
	else:
		print('0', end='')


(n, m) = map(int, input().split(' '))
c = {x: 0 for x in range(1, n + 1)}
res = list()
uniq = {x for x in range(1, n + 1)}
for i in list(map(int, input().split(' '))):
	c[i] += 1
	if i in uniq:
		uniq.remove(i)
		if len(uniq) == 0:
			c = {x: value - 1 for (x, value) in c.items() if value > 0}
			uniq = {key for (key, value) in c.items() if value == 0}
			res.append('1')
		else:
			res.append('0')
	else:
		res.append('0')
print(''.join(res))


import sys
from math import *
from copy import copy
import pdb
import itertools
from pprint import pprint
from collections import deque
(n, m) = [int(i) for i in input().split()]
dat = [int(i) for i in input().split()]
st = set()
dic = {}
for i in range(1, n + 1):
	dic[i] = 0
	st.add(i)
cnt = 0
for i in dat:
	ans = 1
	dic[i] += 1
	if i in st:
		st.remove(i)
	if len(st) == 0:
		print(1, end='')
		cnt += 1
		for (k, i) in dic.items():
			if i <= cnt:
				st.add(k)
	else:
		print(0, end='')


(a, b) = map(int, input().split())
d = {}
s = 0
for i in map(int, input().split()):
	d[i] = d.get(i, 0) + 1
	if len(d) == a:
		print(1, end='')
		r = [i for i in d]
		for j in r:
			d[j] -= 1
			if d[j] == 0:
				d.pop(j)
	else:
		print(0, end='')


(n, m) = map(int, input().split())
a = [*map(int, input().split())]
b = {}
for i in range(1, n + 1):
	b[i] = 0
t = 0
ans = ''
for i in a:
	if b[i] == 0:
		t += 1
	b[i] += 1
	if t == n:
		ans += '1'
		t = 0
		for i in b.keys():
			b[i] -= 1
			if b[i]:
				t += 1
	else:
		ans += '0'
print(ans)


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

def main():
	(n, m) = map(int, input().split())
	problems = list(map(int, input().split()))
	ans = []
	d = {}
	for problem in problems:
		if problem not in d:
			d[problem] = 0
		d[problem] += 1
		if len(d) == n:
			ans.append('1')
			d = {key: val - 1 for (key, val) in d.items() if val > 1}
		else:
			ans.append('0')
	print(''.join(ans))
main()


import sys
from collections import Counter
(N, M) = map(int, input().split())
A = list(map(int, input().split()))
probs = [0] * N
for a in A:
	probs[a - 1] += 1
contest = min(probs)
ans = [0] * M
for i in reversed(range(M)):
	a = A[i]
	if probs[a - 1] == contest:
		ans[i] = 1
		contest -= 1
	probs[a - 1] -= 1
print(''.join(map(str, ans)))


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
a = n * [0]
cnt = n
for i in range(m):
	if a[x[i] - 1] == 0:
		cnt -= 1
		if cnt == 0:
			print(1, end='')
			for j in range(n):
				a[j] -= 1
			cnt = a.count(0) + 1
		else:
			print(0, end='')
	else:
		print(0, end='')
	a[x[i] - 1] += 1


(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)
(n, m) = zz()
arr = zzz()
(x, y) = ([0] * n, [0] * m)
s = ''
for i in arr:
	x[i - 1] += 1
	y[x[i - 1] - 1] += 1
	if y[x[i - 1] - 1] == n:
		print(1, end='')
	else:
		print(0, end='')
print(s)


(n, m) = map(int, input().split())
arr = [int(x) for x in input().split()]
d = {}
for i in range(1, n + 1):
	d[i] = 0
tmp = set()
for i in arr:
	d[i] += 1
	tmp.add(i)
	if len(tmp) == n:
		print('1', end='')
		for i in d:
			d[i] -= 1
		tmp = set()
		for i in d:
			if d[i] > 0:
				tmp.add(i)
	else:
		print('0', end='')


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
dp = [0] * (n + 1)
c = [0] * (m + n)
for i in range(m):
	dp[a[i]] += 1
	c[dp[a[i]]] += 1
	if c[dp[a[i]]] == n:
		print('1', end='')
	else:
		print('0', end='')


(a, b) = map(int, input().split())
s = set()
c = [0] * (a + 1)
for i in map(int, input().split()):
	s.add(i)
	c[i] += 1
	if len(s) == a:
		k = []
		print('1', end='')
		for ele in s:
			c[ele] -= 1
			if c[ele] == 0:
				k.append(ele)
		for ele in k:
			s.remove(ele)
	else:
		print('0', end='')


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = dict()
for i in range(len(a)):
	b[a[i]] = b.get(a[i], 0)
	b[a[i]] += 1
	if len(b) == n:
		print('1', end='')
		c = []
		for k in b:
			b[k] -= 1
			if b[k] == 0:
				c.append(k)
		for j in range(len(c)):
			del b[c[j]]
	else:
		print('0', end='')


(n, k) = (int(x) for x in input().split())
L = [int(x) for x in input().split()]
G = [0 for i in range(k)]
D = [[] for i in range(n)]
s = 0
ss = 0
for i in range(k):
	D[L[i] - 1].append(i)
m = k + 1
for i in D:
	if m > len(i):
		m = len(i)
for i in range(m):
	mm = 0
	for j in D:
		if j[i] > mm:
			mm = j[i]
	G[mm] = 1
for i in G:
	print(i, end='')


class Solution(object):

	def getContestHeldArray(self, n, m, arr):
		diff_set = {}
		for num in arr:
			if num not in diff_set:
				diff_set[num] = 1
			else:
				diff_set[num] += 1
			if len(diff_set) == m:
				print(1, end='')
				for d in range(1, m + 1):
					diff_set[d] -= 1
					if diff_set[d] == 0:
						del diff_set[d]
			else:
				print(0, end='')
		print()

def read_input():
	return [int(x) for x in input().split()]
line = read_input()
m = line[0]
n = line[1]
arr = read_input()
sol = Solution()
sol.getContestHeldArray(n, m, arr)


def f(a, n):
	st = set([i for i in range(1, n + 1)])
	d = {}
	s = set()
	ans = ''
	for i in a:
		d[i] = d.get(i, 0) + 1
		s.add(i)
		if s == st:
			for j in st:
				d[j] -= 1
				if d[j] == 0:
					s.remove(j)
			ans += '1'
		else:
			ans += '0'
	return ans
(a, b) = map(int, input().strip().split())
l = list(map(int, input().strip().split()))
print(f(l, a))


def check_winner(header, data):
	round_size = int(header.split(' ')[0])
	split_data = data.split(' ')
	data_set = [str(i + 1) for i in range(round_size)]
	data_dict = {}
	output = []
	a_set = set()
	for num in data_set:
		data_dict[num] = 0
	for num in split_data:
		data_dict[num] += 1
		a_set.add(num)
		if len(a_set) == round_size:
			a_set.clear()
			for i in data_set:
				data_dict[i] -= 1
				if data_dict[i] > 0:
					a_set.add(i)
			output.append('1')
		else:
			output.append('0')
	return ''.join(output)
header = input()
data = input()
print(check_winner(header, data))


import sys

def main():
	(nLevels, nTasks) = list(map(int, sys.stdin.readline().rstrip('\n').split(' ')))
	problemLevels = list(map(int, sys.stdin.readline().rstrip('\n').split(' ')))
	diffsCount = dict()
	for level in problemLevels:
		diffsCount[level] = diffsCount.get(level, 0) + 1
		if len(diffsCount) == nLevels:
			print(1, end='')
			keysToRemove = []
			for key in diffsCount:
				diffsCount[key] -= 1
				if diffsCount[key] == 0:
					keysToRemove.append(key)
			for keyToRemove in keysToRemove:
				diffsCount.pop(keyToRemove)
		else:
			print(0, end='')
main()


(n, m) = map(int, input().split())
problems = map(int, input().split())
making = {}
count = 0
summer = n * (n + 1) / 2
returner = []
for i in problems:
	if i in making and making[i] != 0:
		making[i] += 1
		returner.append('0')
	else:
		making[i] = 1
		count += 1
		if count == n:
			for x in range(1, n + 1):
				making[x] -= 1
				if making[x] == 0:
					count -= 1
			returner.append('1')
		else:
			returner.append('0')
print(''.join(returner))


from sys import stdin, stdout, setrecursionlimit
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nlargest
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm, accumulate
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time
setrecursionlimit(10 ** 9)
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return input()

def num():
	return int(input())

def L():
	return list(sp())

def LF():
	return list(spf())

def sl():
	return list(ssp())

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

def spf():
	return map(int, input.readline().split())

def ssp():
	return map(str, data().split())

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

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

def pmat(A):
	for ele in A:
		print(*ele, end='\n')

def pmat2(A):
	for ele in A:
		for j in ele:
			print(j, end='')
		print()

def iseven(n):
	return n % 2 == 0

def seive(r):
	prime = [1 for i in range(r + 1)]
	prime[0] = 0
	prime[1] = 0
	for i in range(r + 1):
		if prime[i]:
			for j in range(2 * i, r + 1, i):
				prime[j] = 0
	return prime

def generate_all_sets(n, a):
	big_ans = []
	for i in range(1 << n):
		ans = []
		for j in range(n):
			if i & 1 << j:
				ans.append(a[j])
		big_ans.append(ans)
	return big_ans
(n, m) = sp()
a = sp()
d = dict()
for i in a:
	d[i] = d.get(i, 0) + 1
	if len(d) == n:
		for i in range(1, n + 1):
			d[i] -= 1
			if d[i] == 0:
				d.pop(i)
		print('1', end='')
	else:
		print('0', end='')
endtime = time.time()


from collections import defaultdict
(maxi, _) = input().split()
maxi = int(maxi)
problems = list(map(int, input().split()))
dificuldades = defaultdict(int)
retorno = ''
for difi in problems:
	dificuldades[difi] += 1
	if len(dificuldades) == maxi:
		retirar = []
		retorno += '1'
		for (k, v) in dificuldades.items():
			if v == 1:
				retirar.append(k)
			else:
				dificuldades[k] = v - 1
		for k in retirar:
			del dificuldades[k]
	else:
		retorno += '0'
print(retorno)


(n, m) = [int(v) for v in input().split()]
a = [int(v) - 1 for v in input().split()]
cnt = [0] * n
nonzero = 0
ans = []
for ai in a:
	cnt[ai] += 1
	if cnt[ai] == 1:
		nonzero += 1
		if nonzero == n:
			nonzero = 0
			for i in range(n):
				cnt[i] -= 1
				if cnt[i]:
					nonzero += 1
			ans.append(True)
			continue
	ans.append(False)
print(''.join(('01'[v] for v in ans)))


import sys
input = sys.stdin.readline
(N, M) = map(int, input().split())
A = [int(x) for x in input().split()]
K = [0] * (N + 1)
H = set()
S = ''
for a in A:
	H.add(a)
	K[a] += 1
	if len(H) == N:
		S += '1'
		H = set()
		for i in range(1, N + 1):
			K[i] -= 1
			if K[i] >= 1:
				H.add(i)
	else:
		S += '0'
print(S)


def main():
	(n, m) = input().split(' ')
	n = int(n)
	m = int(m)
	arr = input().split(' ')
	for i in range(m):
		arr[i] = int(arr[i])
	pr = set()
	st = ''
	cts = [0 for i in range(n)]
	for i in range(m):
		pr.add(arr[i])
		cts[arr[i] - 1] = cts[arr[i] - 1] + 1
		if len(pr) == n:
			st = st + '1'
			for j in range(n):
				cts[j] = cts[j] - 1
				if cts[j] == 0:
					pr.remove(j + 1)
		else:
			st = st + '0'
	print(st)
main()


from collections import defaultdict, deque, Counter
from sys import stdin, stdout
from heapq import heappush, heappop
import math
import io
import os
import math
import bisect

def isPrime(x):
	for i in range(2, x):
		if i * i > x:
			break
		if x % i == 0:
			return False
	return True

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(int(i))
			n = n / i
	if n > 2:
		l.append(n)
	return list(set(l))

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 sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def digits(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def ceil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

def mapin():
	return map(int, input().split())
(n, m) = mapin()
l = [int(x) for x in input().split()]
x = 0
f = [0] * m
dd = [0] * n
for i in range(m):
	if dd[l[i] - 1] == 0:
		dd[l[i] - 1] = 1
		x += 1
	else:
		dd[l[i] - 1] += 1
	if x == n:
		f[i] = 1
		x = 0
		for j in range(n):
			dd[j] -= 1
			if dd[j] > 0:
				x += 1
for i in f:
	print(i, end='')
print('')


input = __import__('sys').stdin.readline
(n, m) = map(int, input().split())
D = [*map(int, input().split())]
Di = [0] * n
k = [0] * m
t = 0
Dp = [0] * m
for i in range(m):
	m = D[i] - 1
	Di[m] += 1
	Dp[Di[m] - 1] += 1
	if Dp[t] == n:
		k[i] = 1
		t += 1
print(''.join(map(str, k)))


(n, m) = map(int, input().strip().split(' '))
lst = list(map(int, input().strip().split(' ')))
l = [0] * n
l1 = []
k = 1
for i in range(m):
	l[lst[i] - 1] += 1
	l1.append(l[lst[i] - 1])
c = [0] * m
k = 0
for i in range(m):
	c[l1[i] - 1] += 1
	if c[k] == n:
		print('1', end='')
		k += 1
	else:
		print('0', end='')


nm = input().split()
n = int(nm[0])
m = int(nm[1])
a = [int(i) for i in input().split()]
l = [0 for i in range(n)]
cr = [1 for i in range(n)]
lcr = n
s = []
for pr in a:
	if lcr == 1 and cr[pr - 1] == 1:
		s.append('1')
		lcr = 0
		l[pr - 1] += 1
		for i in range(n):
			l[i] -= 1
			if l[i] == 0:
				cr[i] = 1
				lcr += 1
			else:
				cr[i] = 0
	else:
		s.append('0')
		if cr[pr - 1] == 1:
			l[pr - 1] = 1
			cr[pr - 1] = 0
			lcr -= 1
		else:
			l[pr - 1] += 1
print(''.join(s))


from sys import stdin, stdout
I = stdin.readline
P = stdout.write
(n, m) = map(int, I().split())
arr = [int(x) for x in I().split()]
ans = []
occ = [0 for i in range(n)]
freq = [0 for i in range(n)]
l = 0
con = 1
for i in arr:
	freq[i - 1] += 1
	if occ[i - 1] == 0:
		l += 1
		occ[i - 1] = 1
	if l == n:
		l = 0
		occ = [0] * n
		for y in range(n):
			if freq[y] > 0:
				freq[y] -= 1
				if freq[y] >= 1 and occ[y] == 0:
					occ[y] = 1
					l += 1
		ans.append('1')
	else:
		ans.append('0')
P(''.join(ans))


(n, m) = input().split()
li = input().split()
li = tuple(map(int, li))
n = int(n)
m = int(m)
n1 = []
s1 = ''
y = 0
p = [-1] * n
z = 0
for i in li:
	if len(n1) == 0 or i in n1[-1]:
		s = set()
		s.add(i)
		n1.append(s)
		p[i - 1] = p[i - 1] + 1
	else:
		p[i - 1] = p[i - 1] + 1
		n1[p[i - 1]].add(i)
	if len(n1[z]) == n:
		z += 1
		s1 = s1 + '1'
	else:
		s1 = s1 + '0'
print(s1)


(n, m) = [int(i) for i in input().split()]
state = [0] * (n + 1)
curr = 0
a = [int(i) for i in input().split()]
for i in a:
	state[i] += 1
	if state[i] == 1:
		curr += 1
	if curr == n:
		print(1, end='')
		for i in range(1, len(state)):
			state[i] -= 1
			if state[i] == 0:
				curr -= 1
	else:
		print(0, end='')


from sys import *
(n, m) = map(int, stdin.readline().split())
arr = list(map(int, stdin.readline().split()))
satisfied = [0] * 100005
meet = dict()
ans = []
cur = 1
for a in arr:
	if a not in meet:
		meet[a] = 1
		satisfied[1] += 1
	else:
		meet[a] += 1
		satisfied[meet[a]] += 1
	if satisfied[cur] == n:
		ans.append('1')
		cur += 1
	else:
		ans.append('0')
print(''.join(ans))


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
k = [0] * (n + 1)
b = [0] * (m + 1)
t = 0
for c in a:
	k[c] += 1
	b[k[c]] += 1
	if b[t + 1] >= n:
		print('1', end='')
		t += 1
	else:
		print('0', end='')


import sys
(n, m) = map(int, sys.stdin.readline().split())
l = list(map(int, sys.stdin.readline().split()))
arr = [0] * n
ans = ''
a = [1, 2, 3]
b = [1, 2, 1]
s = set()
distinct = 0
for i in range(m):
	arr[l[i] - 1] += 1
	if arr[l[i] - 1] == 1:
		distinct += 1
	if distinct == n:
		ans += '1'
		for j in range(n):
			if arr[j] == 1:
				distinct -= 1
			arr[j] -= 1
	else:
		ans += '0'
print(ans)


s = input().split()
n = int(s[0])
m = int(s[1])
problems = (int(i) - 1 for i in input().split())
cur_tasks = [0] * n
need = n
thr = 1
ready = [0] * n
for i in problems:
	cur_tasks[i] += 1
	if cur_tasks[i] >= thr and ready[i] == 0:
		ready[i] = 1
		need -= 1
	if need == 0:
		print(1, end='')
		need = n
		thr += 1
		ready = [0] * n
		for i in range(n):
			if cur_tasks[i] >= thr:
				ready[i] = 1
				need -= 1
	else:
		print(0, end='')


Max = 100001
(n, m) = map(int, input().split())
arr = map(int, input().split())
a = [0] * Max
b = [0] * Max
ans = ''
for i in arr:
	a[i] += 1
	b[a[i]] += 1
	ans += str([0, 1][1 if b[a[i]] == n else 0])
print(ans)


(n, m) = map(int, input().split())
lst = list(map(int, input().split()))
(d, res, k) = ({i: 0 for i in range(1, n + 1)}, '', 0)
for (i, x) in enumerate(lst):
	if d[x] == 0:
		k += 1
	d[x] += 1
	if k == n:
		res += '1'
		for (i, x) in enumerate(d):
			d[x] -= 1
			if d[x] == 0:
				k -= 1
	else:
		res += '0'
print(res)


from collections import defaultdict, deque
(n, m) = list(map(int, input().split()))
diffs = list(map(int, input().split()))
pos = defaultdict(deque)
for (i, x) in enumerate(diffs):
	pos[x].append(i)
succ_pos = []
done = False
while not done:
	contest = []
	for (dif, poses) in pos.items():
		if len(poses) == 0:
			done = True
			break
		contest.append(poses.popleft())
	if not done and len(contest) == n:
		succ_pos.append(max(contest))
crt = 0
for i in range(m):
	if crt < len(succ_pos) and i == succ_pos[crt]:
		print('1', end='')
		crt += 1
	else:
		print('0', end='')


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
s = 0
b = [0] * (n + 1)
for i in a:
	if b[i] == 0:
		s += 1
	b[i] += 1
	if s == n:
		print(1, end='')
		for i in range(n):
			b[i + 1] -= 1
			if b[i + 1] == 0:
				s -= 1
	else:
		print(0, end='')


from sys import stdin, stdout
import cProfile, math
from collections import Counter
from bisect import bisect_left, bisect, bisect_right
import itertools
from copy import deepcopy
from fractions import Fraction
import sys, threading
sys.setrecursionlimit(10 ** 6)
threading.stack_size(2 ** 27)
printHeap = str()
memory_constrained = False
P = 10 ** 9 + 7
import sys
sys.setrecursionlimit(10000000)

class Operation:

	def __init__(self, name, function, function_on_equal, neutral_value=0):
		self.name = name
		self.f = function
		self.f_on_equal = function_on_equal

def add_multiple(x, count):
	return x * count

def min_multiple(x, count):
	return x

def max_multiple(x, count):
	return x
sum_operation = Operation('sum', sum, add_multiple, 0)
min_operation = Operation('min', min, min_multiple, 1000000000.0)
max_operation = Operation('max', max, max_multiple, -1000000000.0)

class SegmentTree:

	def __init__(self, array, operations=[sum_operation, min_operation, max_operation]):
		self.array = array
		if type(operations) != list:
			raise TypeError('operations must be a list')
		self.operations = {}
		for op in operations:
			self.operations[op.name] = op
		self.root = SegmentTreeNode(0, len(array) - 1, self)

	def query(self, start, end, operation_name):
		if self.operations.get(operation_name) == None:
			raise Exception('This operation is not available')
		return self.root._query(start, end, self.operations[operation_name])

	def summary(self):
		return self.root.values

	def update(self, position, value):
		self.root._update(position, value)

	def update_range(self, start, end, value):
		self.root._update_range(start, end, value)

	def __repr__(self):
		return self.root.__repr__()

class SegmentTreeNode:

	def __init__(self, start, end, segment_tree):
		self.range = (start, end)
		self.parent_tree = segment_tree
		self.range_value = None
		self.values = {}
		self.left = None
		self.right = None
		if start == end:
			self._sync()
			return
		self.left = SegmentTreeNode(start, start + (end - start) // 2, segment_tree)
		self.right = SegmentTreeNode(start + (end - start) // 2 + 1, end, segment_tree)
		self._sync()

	def _query(self, start, end, operation):
		if end < self.range[0] or start > self.range[1]:
			return None
		if start <= self.range[0] and self.range[1] <= end:
			return self.values[operation.name]
		self._push()
		left_res = self.left._query(start, end, operation) if self.left else None
		right_res = self.right._query(start, end, operation) if self.right else None
		if left_res is None:
			return right_res
		if right_res is None:
			return left_res
		return operation.f([left_res, right_res])

	def _update(self, position, value):
		if position < self.range[0] or position > self.range[1]:
			return
		if position == self.range[0] and self.range[1] == position:
			self.parent_tree.array[position] = value
			self._sync()
			return
		self._push()
		self.left._update(position, value)
		self.right._update(position, value)
		self._sync()

	def _update_range(self, start, end, value):
		if end < self.range[0] or start > self.range[1]:
			return
		if start <= self.range[0] and self.range[1] <= end:
			self.range_value = value
			self._sync()
			return
		self._push()
		self.left._update_range(start, end, value)
		self.right._update_range(start, end, value)
		self._sync()

	def _sync(self):
		if self.range[0] == self.range[1]:
			for op in self.parent_tree.operations.values():
				current_value = self.parent_tree.array[self.range[0]]
				if self.range_value is not None:
					current_value = self.range_value
				self.values[op.name] = op.f([current_value])
		else:
			for op in self.parent_tree.operations.values():
				result = op.f([self.left.values[op.name], self.right.values[op.name]])
				if self.range_value is not None:
					bound_length = self.range[1] - self.range[0] + 1
					result = op.f_on_equal(self.range_value, bound_length)
				self.values[op.name] = result

	def _push(self):
		if self.range_value is None:
			return
		if self.left:
			self.left.range_value = self.range_value
			self.right.range_value = self.range_value
			self.left._sync()
			self.right._sync()
			self.range_value = None

	def __repr__(self):
		ans = '({}, {}): {}\n'.format(self.range[0], self.range[1], self.values)
		if self.left:
			ans += self.left.__repr__()
		if self.right:
			ans += self.right.__repr__()
		return ans

def display(string_to_print):
	stdout.write(str(string_to_print) + '\n')

def primeFactors(n):
	factors = dict()
	for i in range(2, math.ceil(math.sqrt(n)) + 1):
		while n % i == 0:
			if i in factors:
				factors[i] += 1
			else:
				factors[i] = 1
			n = n // i
	if n > 2:
		factors[n] = 1
	return factors

def isprime(n):
	if n < 4:
		return True
	if n % 2 == 0:
		return False
	if n % 3 == 0:
		return False
	i = 5
	w = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += w
		w = 6 - w
	return True

def test_print(*args):
	if testingMode:
		print(args)

def display_list(list1, sep=' '):
	stdout.write(sep.join(map(str, list1)) + '\n')

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

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

def get_list():
	return list(map(int, stdin.readline().split()))
memory = dict()

def clear_cache():
	global memory
	memory = dict()

def cached_fn(fn, *args):
	global memory
	if args in memory:
		return memory[args]
	else:
		result = fn(*args)
		memory[args] = result
		return result
TestCases = False
testingMode = False
optimiseForReccursion = False

def get_available(li):
	c = 0
	for i in li:
		if i > 0:
			c += 1
	return c

def main():
	(n, m) = get_tuple()
	li = get_list()
	x = [0 for _ in range(n)]
	res = [0 for _ in range(m)]
	available_for = [0 for _ in range(m)]
	availed = 0
	for (index, i) in enumerate(li):
		available_for[x[i - 1]] += 1
		if x[i - 1] == availed:
			if available_for[availed] == n:
				res[index] = 1
				availed += 1
		x[i - 1] += 1
	print(''.join(map(str, res)))
if TestCases:
	for _ in range(get_int()):
		cProfile.run('main()') if testingMode else main()
else:
	(cProfile.run('main()') if testingMode else main()) if not optimiseForReccursion else threading.Thread(target=main).start()


(n, m) = map(int, input().split())
num = list(map(int, input().split()))
freq = [0 for i in range(n)]
dif = 0
resp = ''
for i in range(m):
	if freq[num[i] - 1] == 0:
		dif += 1
	freq[num[i] - 1] += 1
	if dif == n:
		for elem in range(n):
			freq[elem] -= 1
			if freq[elem] == 0:
				dif -= 1
		resp += str(1)
	else:
		resp += str(0)
print(resp)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
a = n * [0]
check = n
for i in range(k):
	if a[l[i] - 1] == 0:
		check -= 1
	a[l[i] - 1] += 1
	if check == 0:
		print(1, end='')
		for j in range(n):
			a[j] -= 1
			if a[j] == 0:
				check += 1
	else:
		print(0, end='')


(n, m) = map(int, input().split())
A = list(map(int, input().split()))
LIST = [[] for i in range(n + 1)]
for i in range(m):
	LIST[A[i]].append(i)
L = 10 ** 6
for i in range(1, n + 1):
	if len(LIST[i]) < L:
		L = len(LIST[i])
ANSLIST = []
for i in range(L):
	ANSLIST.append(max([LIST[k][i] for k in range(1, n + 1)]))
ANS = [0] * m
for a in ANSLIST:
	ANS[a] = 1
for a in ANS:
	print(a, end='')


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
s = set()
b = set()
c = [0] * 100005
cnt = 0
for i in a:
	if i not in s:
		s.add(i)
	else:
		b.add(i)
		c[i] += 1
	if len(s) == n:
		print(1, end='')
		s = set(b)
		for j in s:
			c[j] -= 1
			if c[j] == 0:
				b.discard(j)
	else:
		print(0, end='')


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
ans = ['0' for i in range(m)]
count = [0 for i in range(n + 1)]
check = [0 for i in range(m + 1)]
c = 1
for i in range(m):
	count[arr[i]] += 1
	check[count[arr[i]]] += 1
	if check[c] == n:
		ans[i] = '1'
		c += 1
print(''.join(ans))


(m, n) = map(int, input().split())
arr = list(map(int, input().split()))
d = dict()
l = 0
st = ''
for i in range(n):
	if arr[i] not in d:
		l += 1
		d[arr[i]] = 1
		if l == m:
			st += '1'
			key_list = list(d.keys())
			for item in key_list:
				d[item] -= 1
				if d[item] == 0:
					del d[item]
					l -= 1
		else:
			st += '0'
	else:
		d[arr[i]] += 1
		st += '0'
print(st)


(n, m) = map(int, input().split())
s = [int(x) for x in input().split()]
pos = [0] * n
stk = 0
ans = []
if m < n:
	print('0' * m)
else:
	for j in range(0, len(s)):
		if pos[s[j] - 1] == 0:
			pos[s[j] - 1] = 1
			stk = stk + 1
		else:
			pos[s[j] - 1] = pos[s[j] - 1] + 1
		if stk == n:
			ans.append('1')
			stk = 0
			for k in range(0, n):
				pos[k] = pos[k] - 1
				if pos[k] > 0:
					stk = stk + 1
		else:
			ans.append('0')
ans = ''.join(ans)
print(ans)


(n, m) = map(int, input().rstrip().split())
problems = list(map(int, input().rstrip().split()))
diffdic = [0] * (n + 1)
difflevels = [0] * 10 ** 6
answers = []
for i in range(m):
	diffdic[int(problems[i])] += 1
	difflevels[diffdic[int(problems[i])]] += 1
	if difflevels[diffdic[int(problems[i])]] == n:
		answers.append('1')
	else:
		answers.append('0')
print(''.join(answers))


input = __import__('sys').stdin.readline
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = [0] * (n + 1)
c = [0] * (m + 1)
ans = [0] * m
top = 1
for i in range(m):
	b[a[i]] += 1
	c[b[a[i]]] += 1
	if c[top] == n:
		ans[i] = 1
		top += 1
print(''.join(map(str, ans)))


(n_conteste, n_entradas) = map(int, input().split(' '))
problemas = input().split(' ')
bolsa_problemas = {}
conteste = []
quantidade_por_tipo = 0
for problema in problemas:
	if bolsa_problemas.get(problema) == None:
		bolsa_problemas[problema] = 1
		quantidade_por_tipo += 1
	else:
		if bolsa_problemas[problema] == 0:
			quantidade_por_tipo += 1
		bolsa_problemas[problema] += 1
	if quantidade_por_tipo >= n_conteste:
		conteste.append('1')
		for problema in bolsa_problemas.keys():
			bolsa_problemas[problema] -= 1
			if bolsa_problemas[problema] == 0:
				quantidade_por_tipo -= 1
	else:
		conteste.append('0')
print(''.join(conteste))


from collections import defaultdict
(problem_in_round, problems) = [int(x) for x in input().split()]
difficulties = [int(x) for x in input().split()]
teams = defaultdict(list)
counts = defaultdict(int)
for i in difficulties:
	counts[i] += 1
	teams[counts[i]].append(i)
	if len(teams[counts[i]]) == problem_in_round:
		print('1', end='')
	else:
		print('0', end='')


import sys
import math
import collections
import operator as op
from collections import deque
from math import gcd, inf, sqrt
from bisect import bisect_right, bisect_left
from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2 ** 20)

def factorial(n):
	if n == 0:
		return 1
	return n * factorial(n - 1)

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return len(set(factors))

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def factors(n):
	return list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def printp(p):
	for i in p:
		print(i)
MOD = 10 ** 9 + 7
T = 1
for _ in range(T):
	(n, m) = list(map(int, stdin.readline().split()))
	a = list(map(int, stdin.readline().split()))
	d = {}
	ans = ''
	for i in range(m):
		if a[i] not in d:
			d[a[i]] = 1
		else:
			d[a[i]] += 1
		if len(d) != n:
			ans += '0'
		else:
			ans += '1'
			ix = []
			for i in d:
				d[i] -= 1
				if d[i] == 0:
					ix.append(i)
			for i in ix:
				del d[i]
	print(ans)


def ints():
	return list(map(int, input().split()))
(n, le) = ints()
l = ints()
d = [0] * n
res = ''
dis = 0

def chk(n):
	global d
	global dis
	for i in range(n):
		d[i - 1] -= 1
		if d[i - 1] == 0:
			dis -= 1
for i in range(le):
	d[l[i] - 1] += 1
	if d[l[i] - 1] == 1:
		dis += 1
	if dis == n:
		chk(n)
		print(1, end='')
	else:
		print(0, end='')


(n, m) = map(int, input().split())
(a, ans) = ([0] * (n + 1), [])
b = list(map(int, input().split()))
o = n
for i in b:
	if a[i] == 0:
		o -= 1
	a[i] += 1
	if o == 0:
		for i in range(n):
			if a[i + 1] == 1:
				o += 1
			a[i + 1] -= 1
		ans.append('1')
	else:
		ans.append('0')
print(*ans, sep='')


(n, m) = [int(x) for x in input().split()]
L = [int(x) for x in input().split()]
D2 = {}
T = {}
ans = ''
for i in L:
	if i in D2:
		D2[i] += 1
	else:
		D2[i] = 1
	if D2[i] in T:
		T[D2[i]].append(i)
	else:
		T[D2[i]] = [i]
	if len(T[D2[i]]) % n == 0:
		ans = ans + '1'
	else:
		ans = ans + '0'
print(ans)


from collections import defaultdict
(n, m) = map(int, input().split())
List = [int(x) for x in input().split()]
Dict = defaultdict(bool)
Numbers = defaultdict(int)
Ans = str()
count = 0
for i in range(m):
	if Dict[List[i]] == False:
		Dict[List[i]] = True
		count += 1
		Numbers[List[i]] += 1
	else:
		Numbers[List[i]] += 1
	if count == n:
		Ans += '1'
		count = 0
		Dict = defaultdict(int)
		for i in range(1, n + 1):
			Numbers[i] -= 1
			if Numbers[i] > 0:
				Dict[i] = True
				count += 1
	else:
		Ans += '0'
print(Ans)


(n, m) = list(map(int, input().split()))
a2 = set(range(1, n + 1))
a = list(map(int, input().split()))
a1 = set()
ans = ''
ns = {}
for i in a:
	a1.add(i)
	if i in ns:
		ns[i] = ns[i] + 1
	else:
		ns[i] = 1
	if a1 == a2:
		nns = {}
		for i in ns:
			ns[i] = ns[i] - 1
			if ns[i] != 0:
				nns[i] = ns[i]
		ns = nns
		a1 = set(ns)
		ans += '1'
	else:
		ans += '0'
print(ans)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
s = set()
d = {}
ans = ''
for i in range(m):
	if a[i] in d:
		d[a[i]] += 1
	else:
		d[a[i]] = 1
	c = 0
	if len(d) == n:
		ans += '1'
		for j in range(1, n + 1):
			d[j] -= 1
			if d[j] == 0:
				del d[j]
	else:
		ans += '0'
print(ans)


(n, m) = map(int, input().split())
a = map(int, input().split())
hist = {x + 1: 0 for x in range(n)}
zerocnt = n
for x in a:
	if hist[x] == 0:
		zerocnt -= 1
	hist[x] += 1
	if zerocnt == 0:
		print('1', end='')
		for num in range(n):
			hist[num + 1] -= 1
			if hist[num + 1] == 0:
				zerocnt += 1
	else:
		print('0', end='')


(n, k) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
d = {}
c = []
for i in range(k):
	if a[i] not in d.keys():
		d[a[i]] = 1
	else:
		d[a[i]] += 1
	if len(d) == n:
		c.append(1)
		e = {}
		for i in d.keys():
			if d[i] > 1:
				e[i] = d[i] - 1
		d = e
	else:
		c.append(0)
for i in range(k):
	print(c[i], end='')


def main():
	t = 1
	for _ in range(t):
		(n, m) = map(int, input().split())
		tab = list(map(int, input().split()))
		se = {}
		inc = 0
		for x in range(m):
			if tab[x] in se:
				if se[tab[x]] == 0:
					inc += 1
				se[tab[x]] += 1
			else:
				se[tab[x]] = 1
				inc += 1
			if inc == n:
				for x in range(1, n + 1):
					se[x] -= 1
					if se[x] == 0:
						inc -= 1
				print(1, end='')
			else:
				print(0, end='')
		print()
main()


(N, M) = map(int, input().split())
A = [int(a) for a in input().split()]
X = [0] * N
s = 0
sc = N

def cts():
	global s
	global sc
	s = min(X)
	sc = 0
	for i in range(N):
		if X[i] == s:
			sc += 1
for i in range(M):
	X[A[i] - 1] += 1
	if X[A[i] - 1] == s + 1:
		sc -= 1
		if sc == 0:
			cts()
	if s == 1:
		print(1, end='')
		for j in range(N):
			X[j] -= 1
		s -= 1
	else:
		print(0, end='')
print('')


(n, m) = list(map(int, input().split()))
arr = list(map(int, input().split()))
temp = [0 for i in range(n + 1)]
ans = [0 for i in range(n + m)]
for i in arr:
	temp[i] += 1
	ans[temp[i]] += 1
	if ans[temp[i]] == n:
		print('1', end='')
	else:
		print('0', end='')


from sys import stdin
(n, k) = map(int, stdin.readline().strip().split())
s = list(map(int, stdin.readline().strip().split()))
st = set()
s1 = [0] * (n + 1)
ans = ''
for i in range(len(s)):
	st.add(s[i])
	s1[s[i]] += 1
	if len(st) == n:
		ans = ans + '1'
		for j in range(1, n + 1):
			if s1[j] == 1:
				st.remove(j)
			s1[j] -= 1
	else:
		ans += '0'
print(ans)


(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
cs = dict()
ans = []
for num in a:
	if num in cs:
		cs[num] += 1
	else:
		cs[num] = 1
	if len(cs) == n:
		new = dict()
		for i in list(cs.keys()):
			if cs[i] > 1:
				new[i] = cs[i] - 1
		cs = new
		ans.append('1')
	else:
		ans.append('0')
print(''.join(ans))


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
res = 0
d = {}
s = ''
uni = 0
for i in range(m):
	if d.get(a[i], 0) == 0:
		d[a[i]] = 1
		uni += 1
		if uni == n:
			s += '1'
			for j in range(1, n + 1):
				d[j] -= 1
				if d[j] == 0:
					uni -= 1
		else:
			s += '0'
	else:
		d[a[i]] += 1
		s += '0'
print(s)


(n, d) = input().split()
n = int(n)
d = int(d)
a = list(map(int, input().split()))
i = 1
j = 0
w = 0
m = 1
t = [0] * (n + 1)
st = ''
c = 0
j = 0
for i in range(d):
	if t[a[i]] == 0:
		c += 1
	t[a[i]] += 1
	if c == n:
		st += str(1)
		c = 0
		for i in range(n + 1):
			t[i] -= 1
			if t[i] >= 1:
				c += 1
	else:
		st += str(0)
print(st)


(n, m) = map(int, input().split())
l1 = list(map(int, input().split()))
freq = {}
diff = 0
ans = ''

def update():
	global diff
	for i in range(1, n + 1):
		freq[i] -= 1
		if freq[i] == 0:
			diff -= 1
	return
for i in range(m):
	atual = l1[i]
	if atual not in freq or freq[atual] == 0:
		diff += 1
		freq[atual] = 1
	else:
		freq[atual] += 1
	if diff == n:
		ans += '1'
		update()
	else:
		ans += '0'
print(ans)


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
d = {}
p = []
for i in l:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
	if len(d) == n:
		p.append('1')
		for j in range(1, n + 1):
			d[j] -= 1
			if d[j] == 0:
				del d[j]
	else:
		p.append('0')
t = ''.join(p)
sys.stdout.write(t)


from collections import Counter
c = Counter()
(n, m) = list(map(int, input().split()))
t = list(map(int, input().split()))
s = ''
for i in t:
	if i in c:
		c[i] += 1
	else:
		c[i] = 1
	if len(c) == n:
		for i in range(1, n + 1):
			if c[i] == 1:
				del c[i]
			else:
				c[i] -= 1
		s += '1'
	else:
		s += '0'
print(s)


import sys, string, heapq
(n, m) = map(int, sys.stdin.readline().split())
arr = list(map(int, sys.stdin.readline().split()))
q = [[] for _ in range(n + 1)]
ans = ['0'] * m
for i in range(m):
	heapq.heappush(q[arr[i]], i)
empty = False
while True:
	for i in range(1, n + 1):
		if not q[i]:
			empty = True
			break
	if empty:
		break
	temp = []
	for i in range(1, n + 1):
		temp.append((i, q[i][0]))
		heapq.heappop(q[i])
	temp.sort(key=lambda x: -x[1])
	ans[temp[0][1]] = '1'
print(''.join(ans))


def main():
	(n, m) = input().split()
	n = int(n)
	m = int(m)
	a = [int(i) for i in input().split()]
	count = 0
	freq = [0 for i in range(n)]
	if m < n:
		for i in range(m):
			print('0', end='')
	else:
		for i in range(m):
			if freq[a[i] - 1] == 0:
				count += 1
			freq[a[i] - 1] += 1
			if count == n:
				count = 0
				for j in range(n):
					freq[j] -= 1
					if freq[j] > 0:
						count += 1
				print('1', end='')
			else:
				print('0', end='')
	print()
main()


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
ans = ''
s = set()
d = dict()
for x in a:
	d[x] = d.get(x, 0) + 1
	s.add(x)
	if len(s) == n:
		ans += '1'
		t = s.copy()
		for y in s:
			d[y] -= 1
			if d[y] == 0:
				t.remove(y)
		s = t
	else:
		ans += '0'
print(ans)


(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
b = [0] * n
k = 0
for i in a:
	if b[i - 1] == 0:
		k += 1
	b[i - 1] += 1
	if k == n:
		print(1, end='')
		k = 0
		for j in range(n):
			b[j] -= 1
			k += bool(b[j])
	else:
		print(0, end='')


def main():
	(n, m) = [int(_) for _ in input().split()]
	tasks = [int(_) - 1 for _ in input().split()]
	M = m // n
	tasks_count = [0] * n
	tours = [n] * M
	for t in tasks:
		t_init = tasks_count[t]
		if t_init < M:
			tasks_count[t] += 1
			tours[t_init] -= 1
			if tours[t_init] == 0:
				print(1, end='')
				continue
		print(0, end='')

def test_values():
	X = 100000
	(n, m) = (X, X)
	print(f'{n} {m}')
	for i in range(1, X + 1):
		print(i, end=' ')

def test_values2():
	X = 100000
	(n, m) = (X, X)
	print(f'{n} {m}')
	for i in range(1, X // 2 + 1):
		print(1, end=' ')
		print(2, end=' ')
main()


def check(x, n):
	if x == n:
		return 1
	else:
		return 0
x1 = 100004
lis = input()
l = list(map(int, lis.split(' ')))
n = int(l[0])
m = int(l[1])
li = input()
x = list(map(int, li.split(' ')))
a = [0] * x1
b = [0] * x1
for i in range(0, m):
	a[x[i]] = a[x[i]] + 1
	b[a[x[i]]] = b[a[x[i]]] + 1
	print(check(b[a[x[i]]], n), end='')


import math
from sys import stdin, stdout
I = stdin.readline
P = stdout.write
(n, m) = map(int, I().split())
arr = [int(x) for x in I().split()]
ans = []
dou = [0 for i in range(n)]
f = [0 for i in range(n)]
dl = 0
dd = 0
for i in arr:
	f[i - 1] += 1
	if dou[i - 1] == 0:
		dl += 1
		dou[i - 1] = 1
	if dl == n:
		dou = [0] * n
		dd = 0
		dl = dd
		dd = dl
		for y in range(n):
			if f[y] > 0:
				f[y] -= 1
				if f[y] >= 1 and dou[y] == 0:
					dou[y] = 1
					dd += 1
					dl = dd
		ans.append('1')
	else:
		ans.append('0')
P(''.join(ans))


(n, m) = map(int, input().split())
(*l,) = map(int, input().split())
d = {i: 0 for i in range(n)}
p = set()
for i in l:
	d[i - 1] += 1
	p.add(i - 1)
	if len(p) == n:
		print(1, end='')
		p = set()
		for j in range(n):
			d[j] -= 1
			if d[j]:
				p.add(j)
	else:
		print(0, end='')


(n, m) = map(int, input().split())
a = [*map(int, input().split())]
mn = 1
c = [0] * (m + 1)
v = [0] * (m + 1)
ans = ['0'] * m
if n <= m:
	for i in range(m):
		v[a[i]] += 1
		c[v[a[i]]] += 1
		if c[mn] == n:
			ans[i] = '1'
			mn += 1
print(''.join(ans))


(a, b) = map(int, input().split())
l = list(map(int, input().split()))
c = [int(0) for i in range(1001010)]
count = 0
for i in range(0, b):
	t = int(l[i])
	if c[t] == 0:
		count += 1
		c[t] += 1
		if count == a:
			print(1, end='')
			for j in range(1, a + 1):
				c[j] -= 1
				if c[j] == 0:
					count -= 1
		else:
			print(0, end='')
	else:
		c[t] += 1
		print(0, end='')
print('\n')


(n, m) = map(int, input().split(' '))
lst = list(map(int, input().split(' ')))
s = ''
d = {}
f = [0] * 10000000
for i in range(m):
	f[lst[i]] += 1
	if f[lst[i]] not in d:
		d[f[lst[i]]] = 1
	else:
		d[f[lst[i]]] += 1
	if d[f[lst[i]]] == n:
		s += '1'
	else:
		s += '0'
print(s)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
d = {i: 0 for i in range(1, n + 1)}
rnd = {i: 0 for i in range(1, 100001)}
r = 1
res = ''
for i in l:
	d[i] += 1
	rnd[d[i]] += 1
	if rnd[r] == n:
		res += '1'
		r += 1
	else:
		res += '0'
print(res)


(n, m) = map(int, input().strip().split())
array = list(map(int, input().strip().split()))
result = ''
curr = [0] * (n + 1)
curr[0] = 1
count = 0
for i in range(len(array)):
	curr[array[i]] += 1
	if curr[array[i]] == 1:
		count += 1
	else:
		pass
	if count == n:
		result += '1'
		for i in range(1, len(curr)):
			curr[i] -= 1
			if curr[i] == 0:
				count -= 1
	else:
		result += '0'
print(result)


first = input()
(n, m) = [int(x) for x in first.split()]
n = int(n)
m = int(m)
second = input()
nums = [int(x) for x in second.split()]
probs = {}
probs2 = set()
for prob in nums:
	try:
		probs[prob] += 1
	except:
		probs[prob] = 1
	probs2.add(prob)
	if len(probs2) == n:
		print('1', end='')
		for (a, b) in probs.items():
			probs[a] -= 1
			if probs[a] == 0:
				probs2.remove(a)
	else:
		print('0', end='')


[N, M] = list(map(int, input().split(' ')))
creations = list(map(int, input().split(' ')))
problem_set = [0] * (N + 1)
point = 0
ret = []
criteria = 0
for creation in creations:
	creation -= 1
	problem_set[creation] += 1
	if creation == point:
		while problem_set[point] > criteria:
			point += 1
	if point == N:
		criteria += 1
		point = 0
		while problem_set[point] > criteria:
			point += 1
		ret.append('1')
	else:
		ret.append('0')
ret = ''.join(ret)
print(ret)


import sys
from math import sqrt, gcd, ceil, log
from collections import defaultdict, Counter, deque
input = sys.stdin.readline
read = lambda : list(map(int, input().strip().split()))

def main():
	(n, m) = read()
	arr = read()
	ans = []
	count = defaultdict(int)
	s = 0
	t = n * (n + 1) // 2
	for i in arr:
		if count[i] == 0:
			s += i
		count[i] += 1
		if s == t:
			for i in count:
				count[i] -= 1
				if count[i] == 0:
					s -= i
			ans.append('1')
		else:
			ans.append('0')
	print(''.join(ans))
main()


import sys
from collections import defaultdict
input = sys.stdin.readline
(n, m) = tuple(map(int, input().split()))
a = list(map(int, input().split()))
s = {}
dist = 0
ans = []
for t in a:
	if t in s and s[t] > 0:
		s[t] += 1
		ans.append(0)
	else:
		s[t] = 1
		dist += 1
		if dist == n:
			s = s
			ans.append(1)
			for k in list(s.keys()):
				s[k] -= 1
				if s[k] == 0:
					dist -= 1
		else:
			ans.append(0)
print(''.join(list(map(str, ans))))


(n, m) = map(int, input().split())
probdiffs = list(map(int, input().split()))
a = dict()
for i in probdiffs:
	if i in a:
		a[i] += 1
	else:
		a[i] = 1
	if len(a) == n:
		a2 = dict()
		for j in a:
			if a[j] > 1:
				a2[j] = a[j] - 1
		a = a2
		print(1, end='', sep='')
	else:
		print(0, end='', sep='')


(n, m) = [int(i) for i in input().split(' ')]
a = [int(i) for i in input().split(' ')]
uni_cnt = 0
dic = [0 for i in range(n + 1)]
ans = [0 for i in range(m)]
for (idx, i) in enumerate(a):
	if dic[i] == 0:
		uni_cnt += 1
	dic[i] += 1
	if uni_cnt == n:
		for j in range(1, n + 1):
			dic[j] -= 1
			if dic[j] == 0:
				uni_cnt -= 1
		ans[idx] = 1
print(''.join((str(i) for i in ans)))


import sys
from bisect import bisect_left, bisect_right, insort
from collections import deque, Counter
from math import gcd, sqrt, factorial, ceil, log10, log2, floor
from itertools import permutations
from heapq import heappush, heappop, heapify
inf = float('inf')
mod = 998244353

def factorial_p(n, p):
	ans = 1
	if n <= p // 2:
		for i in range(1, n + 1):
			ans = ans * i % p
	else:
		for i in range(1, p - n):
			ans = ans * i % p
		ans = pow(ans, p - 2, p)
		if n % 2 == 0:
			ans = p - ans
	return ans

def nCr_p(n, r, p):
	ans = 1
	while n != 0 or r != 0:
		(a, b) = (n % p, r % p)
		if a < b:
			return 0
		ans = ans * factorial_p(a, p) * pow(factorial_p(b, p), p - 2, p) * pow(factorial_p(a - b, p), p - 2, p) % p
		n //= p
		r //= p
	return ans

def prime_sieve(n):
	flag = n % 6 == 2
	sieve = bytearray((n // 3 + flag >> 3) + 1)
	for i in range(1, int(n ** 0.5) // 3 + 1):
		if not sieve[i >> 3] >> (i & 7) & 1:
			k = 3 * i + 1 | 1
			for j in range(k * k // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
			for j in range(k * (k - 2 * (i & 1) + 4) // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
	return sieve

def prime_list(n):
	res = []
	if n > 1:
		res.append(2)
	if n > 2:
		res.append(3)
	if n > 4:
		sieve = prime_sieve(n + 1)
		res.extend((3 * i + 1 | 1 for i in range(1, (n + 1) // 3 + (n % 6 == 1)) if not sieve[i >> 3] >> (i & 7) & 1))
	return res

def is_prime(n):
	if n < 5 or n & 1 == 0 or n % 3 == 0:
		return 2 <= n <= 3
	s = (n - 1 & 1 - n).bit_length() - 1
	d = n >> s
	for a in [2, 325, 9375, 28178, 450775, 9780504, 1795265022]:
		p = pow(a, d, n)
		if p == 1 or p == n - 1 or a % n == 0:
			continue
		for _ in range(s):
			p = p * p % n
			if p == n - 1:
				break
		else:
			return False
	return True

def all_factors(n):
	(small, large) = (0, 0)
	count = 0
	for i in range(1, int(n ** 0.5) + 1, 2 if n & 1 else 1):
		if not n % i:
			small = i
			large = n // i
			count += 2
	if small == large:
		count -= 1
	return count

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()
(n, m) = get_ints()
Arr = get_array()
z = ''
b = [0] * n
c = [0] * 200000
for i in range(m):
	x = Arr[i] - 1
	b[x] += 1
	c[b[x]] += 1
	if c[b[x]] == n:
		z += '1'
	else:
		z += '0'
print(z)


(n, m) = map(int, input().split())
a = [int(s) - 1 for s in input().split()]
d = dict()
for i in range(n):
	d[i] = 0
num = n
c = []
for i in a:
	if d[i] == 0:
		num -= 1
	d[i] += 1
	nul = 0
	if num == 0:
		for j in d.keys():
			d[j] -= 1
			if d[j] > 0:
				nul += 1
		c.append('1')
		num = n - nul
	else:
		c.append('0')
print(''.join(c))


import sys
(n, m) = [int(z) for z in sys.stdin.readline().split()]
ds = [int(z) for z in sys.stdin.readline().split()]
dd = dict()
r = []
cd = 0
for d in ds:
	if d in dd:
		dd[d] += 1
	else:
		dd[d] = 1
		cd += 1
	if cd == n:
		r.append(1)
		for td in dd:
			dd[td] -= 1
		zero_difs_in_dd = [zd for (zd, zv) in dd.items() if zv == 0]
		for deld in zero_difs_in_dd:
			del dd[deld]
			cd -= 1
	else:
		r.append(0)
print(*r, sep='')


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
d = {}
s = ''
for i in range(m):
	if a[i] not in d:
		d[a[i]] = 1
	else:
		d[a[i]] += 1
	if len(d) == n:
		s += '1'
		for i in d:
			d[i] -= 1
		d2 = {}
		for i in d:
			if d[i] != 0:
				d2[i] = d[i]
		d = d2.copy()
	else:
		s += '0'
print(s)


(n, m) = map(int, input().split())
(ls, d, c, currmin) = (list(map(lambda x: int(x) - 1, input().split())), [0] * n, 0, 0)
for i in range(min(n, m) - 1):
	d[ls[i]] += 1
	print(0, end='')
for i in range(min(n, m) - 1, m):
	d[ls[i]] += 1
	while currmin < n and d[currmin] > c:
		currmin += 1
	if currmin == n:
		(currmin, c) = (0, c + 1)
		print(1, end='')
	else:
		print(0, end='')
print()


import sys
import math

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

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

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

def read_string_list(delim=' '):
	return input().strip().split(delim)
(n, m) = read_int_list()
arr = read_int_list()
diki = {}
for i in range(m):
	diki[arr[i]] = diki.get(arr[i], 0) + 1
	if len(diki) == n:
		to_be_deleted = []
		for k in diki:
			diki[k] -= 1
			if diki[k] <= 0:
				to_be_deleted.append(k)
		for t in to_be_deleted:
			diki.pop(t)
		print(1, end='')
	else:
		print(0, end='')


from collections import deque
(n, m) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [deque([]) for i in range(n + 1)]
for i in range(m):
	b[a[i]].append(i)
o = False
count = 0
indp = 0
while o == False:
	ind = 0
	for i in range(1, n + 1):
		if len(b[i]) == 0:
			o = True
			break
		ind = max(b[i].popleft(), ind)
	if o == True:
		for i in range(indp, m):
			print(0, end='')
		break
	for i in range(indp, ind):
		print(0, end='')
	indp = ind + 1
	print(1, end='')
print()


(n, m) = map(int, input().split())
problems = list(map(int, input().split()))
aux = [0] * n
total = [0] * m
answer = ''
index = 0
for i in range(m):
	aux[problems[i] - 1] += 1
	total[aux[problems[i] - 1] - 1] += 1
	if total[index] == n:
		answer += '1'
		index += 1
	else:
		answer += '0'
print(answer)


(n, _) = map(int, input().split())
nums = list(map(lambda x: int(x) - 1, input().split()))
l = [0] * n
total = 0
for num in nums:
	if l[num] == 0:
		total += 1
	l[num] += 1
	if total == n:
		print(1, end='')
		total = 0
		for i in range(n):
			l[i] -= 1
			if l[i]:
				total += 1
	else:
		print(0, end='')


(n, m) = map(int, input().split(' '))
y = [int(k) for k in input().split(' ')]
x = [0] * n
z = [0] * m
w = [0] * m
t = i = 0
while i < len(y):
	q = y[i] - 1
	x[q] = x[q] + 1
	z[x[q] - 1] = z[x[q] - 1] + 1
	if z[t] == n:
		w[i] = 1
		t = t + 1
	i = i + 1
for i in w:
	print(i, end='')


(n, m) = [int(i) for i in input().split(' ')]
lista = [int(i) - 1 for i in input().split(' ')]
answer = ''
acumulados = [0] * n
quantidade_de_1 = 0
remaining = n

def verificar_maiores():
	quantidade_maior = 0
	for i in acumulados:
		if i > quantidade_de_1:
			quantidade_maior += 1
	return quantidade_maior
for entrada in lista:
	if acumulados[entrada] == quantidade_de_1:
		remaining -= 1
	acumulados[entrada] += 1
	if remaining == 0:
		quantidade_de_1 += 1
		quantidade_maior = 0
		for i in acumulados:
			if i > quantidade_de_1:
				quantidade_maior += 1
		remaining = n - quantidade_maior
		answer += '1'
	else:
		answer += '0'
print(answer)


from fractions import gcd
from datetime import date
from math import factorial
import functools
from heapq import *
from collections import deque
import collections
import math
from collections import defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
inf = float('inf')

def main():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	l = set()
	ans = ''
	d = defaultdict(int)
	c = 0
	for v in a:
		if d[v] == 0:
			c += 1
		d[v] += 1
		if c == n:
			ans += '1'
			for ke in d.keys():
				d[ke] -= 1
				if d[ke] == 0:
					c -= 1
		else:
			ans += '0'
	print(ans)
main()


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
now = 0
cnt = [0] * n
exist = [0] * m
for i in range(m):
	cnt[a[i] - 1] += 1
	exist[cnt[a[i] - 1] - 1] += 1
	if exist[now] == n:
		print(1, end='')
		now += 1
	else:
		print(0, end='')


(n, m) = map(int, input().split())
c = [0] * (n + 1)
nz = n
tasks = map(int, input().split())
bins = []
for t in tasks:
	if c[t] == 0:
		nz -= 1
	c[t] += 1
	if nz == 0:
		bins.append('1')
		for t in range(1, n + 1):
			if c[t] == 1:
				nz += 1
			c[t] -= 1
	else:
		bins.append('0')
print(''.join(bins))


(n, m) = map(int, input().split())
f = list(map(int, input().split()))
A = [0] * n
B = [0] * (m + 1)
k = 1
g = ''
for i in range(m):
	A[f[i] - 1] += 1
	B[A[f[i] - 1]] += 1
	if B[k] == n:
		g += '1'
		k += 1
	else:
		g += '0'
print(g)


(k, n) = map(int, input().split())
a = [int(x) for x in input().split()]
dp = [0] * (k + 1)
prev = 0
c = 0
s = ''
count = [0] * (n + 1)
for i in a:
	dp[i] += 1
	count[dp[i]] += 1
	if count[dp[i]] == k:
		s += '1'
	else:
		s += '0'
print(s)


(complexity, n_task) = map(int, input().split())
tasks = list(map(int, input().split()))
problems = [0] * (complexity + 1)
ready = 0
for ts in tasks:
	problems[ts] += 1
	if problems[ts] == 1:
		ready += 1
	if ready != complexity:
		print('0', sep='', end='')
	else:
		for j in range(1, complexity + 1):
			problems[j] -= 1
			if problems[j] == 0:
				ready -= 1
		print('1', sep='', end='')


from sys import stdin
from collections import defaultdict
(n, m) = map(int, input().split())
l = list(map(int, stdin.readline().split()))
rd = [0] * (m + 1)
cnt = [0] * (n + 1)
current_round = 1
ans = ['0'] * m
for (i, k) in enumerate(l):
	cnt[k] += 1
	rd[cnt[k]] += 1
	if rd[current_round] == n:
		ans[i] = '1'
		current_round += 1
print(''.join(ans))


inp = [int(item) for item in input().split(' ')]
(n, m) = (inp[0], inp[1])
res1 = {}
for j in range(1, n + 1):
	res1[j] = []
for (i, item) in enumerate([int(item) for item in input().split(' ')]):
	res1[item].append(i)
res1val = list(res1.values())
minLeng = min([len(item) for item in res1val])
res2 = ['0' for i in range(m)]
for k in range(minLeng):
	idx = max([item[k] for item in res1val])
	res2[idx] = '1'
print(''.join(res2))


(n, k) = map(int, input().split())
A = list(map(int, input().split()))
B = [0 for i in range(100003)]
hit = 0
for x in A:
	B[x] += 1
	if B[x] == 1:
		hit += 1
	if hit == n:
		print(1, end='')
		for i in range(1, n + 1):
			B[i] -= 1
			if B[i] == 0:
				hit -= 1
	else:
		print(0, end='')
print('')


(n, m) = map(int, input().split())
occ = [0] * n
cnt = 0
for x in map(int, input().split()):
	occ[x - 1] += 1
	if occ[x - 1] == 1:
		cnt += 1
		if cnt == n:
			print('1', end='')
			for i in range(n):
				occ[i] -= 1
			cnt = n - occ.count(0)
			continue
	print('0', end='')


(n, m) = map(int, input().split())
aa = list(map(int, input().split()))
t = dict()
result = []
for a in aa:
	if a in t.keys():
		t[a] += 1
		result.append('0')
	else:
		t[a] = 1
		if len(t) == n:
			result.append('1')
			for k in range(1, n + 1):
				if t[k] == 1:
					del t[k]
				else:
					t[k] -= 1
		else:
			result.append('0')
print(''.join(result))


l1 = list(map(int, input().split()))
n = l1[0]
m = l1[1]
l = list(map(int, input().split()))
c = [0] * (n + 1)
s = set()
w = ''
i = 0
while i < len(l):
	s.add(l[i])
	c[l[i]] += 1
	if len(s) == n:
		w = w + '1'
		j = 0
		s = set()
		while j < len(c):
			if c[j] > 1:
				c[j] -= 1
				s.add(j)
			else:
				c[j] -= 1
			j += 1
	else:
		w = w + '0'
	i += 1
print(w)


(n, m) = map(int, input().split())
a = list(map(lambda x: int(x) - 1, input().split()))
d = {i: 0 for i in range(n)}
ans = ['' for i in range(m)]
c = set((i for i in range(n)))
p = 0
for i in range(m):
	d[a[i]] += 1
	if a[i] in c:
		c.remove(a[i])
	if len(c) == 0:
		ans[i] = '1'
		for i in range(n):
			d[i] -= 1
			if d[i] <= 0:
				c.add(i)
	else:
		ans[i] = '0'
print(''.join(ans))


(n, m) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
ct = [0] * (n + 1)
cts = 0
for i in a:
	ct[i] += 1
	if ct[i] == 1:
		cts += 1
	if cts == n:
		print(1, end='')
		for j in range(1, n + 1):
			ct[j] -= 1
			if ct[j] == 0:
				cts -= 1
	else:
		print(0, end='')


def distinct(array):
	for i in range(len(array)):
		array[i] -= 1
	return array

def calculate_skips(array):
	skips = 0
	for i in array:
		if i == 0:
			skips += 1
	return skips
ln = input().split(' ')
task_count = int(ln[0])
n = int(ln[1])
array = []
for i in range(task_count):
	array.insert(i, 0)
result = ''
sequence = input().split(' ')
skip_reads = task_count
for s in sequence:
	current_task = int(s) - 1
	array[current_task] += 1
	if array[current_task] == 1:
		skip_reads -= 1
		if skip_reads == 0:
			result += '1'
			array = distinct(array)
			skip_reads = calculate_skips(array)
			continue
	result += '0'
print(result)


(n, m) = list(map(int, input().split()))
c = list(map(int, input().split()))
r = ['0'] * m
x = [0] * (n + 1)
y = [0] * (m + 1)
count = 1
for i in range(m):
	x[c[i]] += 1
	y[x[c[i]]] += 1
	if y[count] == n:
		r[i] = '1'
		count += 1
print(''.join(r))


def main():
	(n, m) = map(int, input().split())
	arr = list(map(int, input().split()))
	if m < n:
		for i in range(m):
			print(0, end='')
	else:
		if n == 1:
			for t in range(0, m):
				print(1, end='')
			return
		lenArr = len(arr)
		countArr = [0] * (n + 1)
		indexArr = [[] for i in range(0, n + 1)]
		for j in range(0, lenArr):
			countArr[arr[j]] += 1
			indexArr[arr[j]].append(j)
		minlen = min(countArr[1:])
		res = []
		for y in range(0, minlen):
			tmpArr = set()
			for z in indexArr[1:]:
				tmpArr.add(z[y])
			res.append(max(tmpArr))
		result = ['0'] * m
		for k in res:
			result[k] = '1'
		result = ''.join(result)
		print(result)
main()


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())
(n, m) = f()
l = il()
lc = [0] * (n + 1)
cp = 0
for i in l:
	if lc[i] == 0:
		cp += 1
		lc[i] += 1
	else:
		lc[i] += 1
	if cp == n:
		print(1, end='')
		for i in range(1, n + 1):
			if lc[i] == 1:
				cp -= 1
			lc[i] -= 1
	else:
		print(0, end='')


(N, M) = map(int, input().split())
a = list(map(lambda x: int(x) - 1, input().split()))
problems = [0] * N
count = 0
ans = []
append = ans.append
for n in a:
	if not problems[n]:
		count += 1
	problems[n] += 1
	append(1 if count == N else 0)
	if count == N:
		count = 0
		for i in range(N):
			problems[i] -= 1
			if problems[i] > 0:
				count += 1
print(*ans, sep='')


(n, m) = map(int, input().split())
ds = list(map(int, input().split()))
pool = [0] * n
zeros_count = n
for d in ds:
	d -= 1
	pool[d] += 1
	if pool[d] == 1:
		zeros_count -= 1
		if zeros_count == 0:
			print('1', end='')
			for i in range(len(pool)):
				pool[i] -= 1
				if pool[i] == 0:
					zeros_count += 1
		else:
			print('0', end='')
	else:
		print('0', end='')


MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from collections import defaultdict as dd
(n, m) = I()
l = I()
d = dd(list)
for i in range(m):
	d[l[i]].append(i)
for i in d:
	d[i].sort()
ans = [0] * m
k = 1
index = 0
while True:
	for i in range(1, n + 1):
		if len(d[i]) < k:
			print(*ans, sep='')
			exit()
		index = max(index, d[i][k - 1])
	k += 1
	ans[index] = 1
print(*ans, sep='')


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
mn = 1
(cnt, cnt2) = ([0 for i in range(n + 1)], [0 for i in range(m + 1)])
for i in range(m):
	cnt[a[i]] += 1
	cnt2[cnt[a[i]]] += 1
	if cnt2[mn] == n:
		print(1, end='')
		mn += 1
	else:
		print(0, end='')
print()


(n, m) = [int(i) for i in input().split()]
state = [0] * (n + 1)
cur = 0
A = [int(i) for i in input().split()]
for i in range(m):
	diff = A[i]
	state[diff] += 1
	if state[diff] == 1:
		cur += 1
	if cur == n:
		print('1', end='')
		for j in range(n + 1):
			state[j] -= 1
			if state[j] == 0:
				cur -= 1
	else:
		print('0', end='')


(p, n) = map(int, input().split())
d = list(map(int, input().split()))
res = ''
track = [0] * (p + 1)
held = 0
uniq = set()
for i in range(n):
	track[d[i]] += 1
	uniq.add(d[i])
	if len(uniq) == p:
		res += '1'
		uniq = set()
		for i in range(1, p + 1):
			track[i] -= 1
			if track[i] > 0:
				uniq.add(i)
	else:
		res += '0'
print(res)


def chPathToThis(f=None):
	import os
	f = __file__ if f is None else f
	os.chdir(os.path.dirname(f))
fle = None

def input():
	global fle

	def inner():
		if fle is None:
			from sys import stdin
			for line in stdin:
				yield line
			raise EOFError
		else:
			for line in fle:
				yield line.replace('\r', '').replace('\n', '')
			raise EOFError
	o = inner()
	return next(o)
import math

class SegmentTree:

	def __init__(self, A):
		self.N = len(A)
		self.st = [0] * (4 * self.N)
		self.build(1, 0, self.N - 1)

	def left(self, idx):
		return idx * 2

	def right(self, idx):
		return idx * 2 + 1

	def build(self, idx, l, r):
		if l == r:
			self.st[idx] = A[l]
		else:
			mid = (l + r) // 2
			self.build(self.left(idx), l, mid)
			self.build(self.right(idx), mid + 1, r)
			self.st[idx] = max(self.st[self.left(idx)], self.st[self.right(idx)])

	def update(self, a, b, val):
		return self.update_recursive(1, 0, self.N - 1, a - 1, b - 1, val)

	def update_recursive(self, idx, l, r, a, b, val):
		if r < a or l > b:
			return True
		if l == r:
			self.st[idx] = val
			return True
		mid = (l + r) // 2
		self.update_recursive(self.left(idx), l, mid, a, b, val)
		self.update_recursive(self.right(idx), mid + 1, r, a, b, val)
		self.st[idx] = max(self.st[self.left(idx)], self.st[self.right(idx)])
		return True

	def query(self, a, b):
		return self.query_recursive(1, 0, self.N - 1, a - 1, b - 1)

	def query_recursive(self, idx, l, r, a, b):
		if r < a or l > b:
			return -math.inf
		if l >= a and r <= b:
			return self.st[idx]
		mid = (l + r) // 2
		q1 = self.query_recursive(self.left(idx), l, mid, a, b)
		q2 = self.query_recursive(self.right(idx), mid + 1, r, a, b)
		return max(q1, q2)

	def showData(self):
		showList = []
		for i in range(1, N + 1):
			showList += [self.query(i, i)]
		print(showList)
A = []
N = 0

def main():
	global A, N
	(n, m) = map(int, input().split())
	a = [int(e) for e in input().split()]
	(A, N) = ([0] * n, n)
	segtree = SegmentTree(A)
	(s, cur) = ('', 0)
	for j in a:
		segtree.update(j, j, segtree.query(j, j) - 1)
		if segtree.query(1, n) < cur:
			cur -= 1
			print('1', end='')
		else:
			print('0', end='')
try:
	import time, numpy
	chPathToThis(__file__)
	(begin, fle) = (time.clock(), open('pytest.txt'))
	main()
	fle.close()
	print(time.clock() - begin)
except ImportError:
	main()


(n, m) = [int(i) for i in input().split(' ')]
a = [int(i) for i in input().split(' ')]
uni_cnt = 0
dic = [0 for _ in range(n + 1)]
ret = [0 for _ in range(m)]
for i in range(m):
	val = a[i]
	if dic[val] == 0:
		uni_cnt += 1
	dic[val] += 1
	if uni_cnt == n:
		for j in range(1, n + 1):
			dic[j] -= 1
			if dic[j] == 0:
				uni_cnt -= 1
		ret[i] = 1
print(''.join((str(i) for i in ret)))


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
d = {}
ans = ['0'] * m
for i in range(m):
	d[arr[i]] = d.get(arr[i], 0) + 1
	if len(d) == n:
		ans[i] = '1'
		k = []
		for j in d:
			d[j] = d.get(j, 0) - 1
			if d[j] <= 0:
				k.append(j)
		for j in k:
			del d[j]
print(''.join(ans))


(n, m) = map(int, input().split())
problems = map(int, input().split())
res = ''
a = [0] * n
count = n
for p in problems:
	if a[p - 1] == 0:
		count -= 1
	a[p - 1] += 1
	if count == 0:
		for i in range(n):
			a[i] -= 1
			if a[i] == 0:
				count += 1
		res += '1'
	else:
		res += '0'
print(res)


import collections
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
difficulty = [0 for i in range(n)]
difficulty_count = [0 for i in range(m + 1)]
ans = ''
contest = 1
for i in range(m):
	difficulty[a[i] - 1] += 1
	difficulty_count[difficulty[a[i] - 1]] += 1
	if difficulty_count[contest] >= n:
		ans += '1'
		contest += 1
	else:
		ans += '0'
print(ans)


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
d = {}
res = ''
for i in arr:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
	is_round = len(d) == n
	res += str(int(is_round))
	if is_round:
		d2 = {}
		for (k, v) in d.items():
			if v > 1:
				d2[k] = v - 1
		d = d2
print(res)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
l = [0] * n
ar = [0] * (m + 1)
if n == 1:
	for i in range(0, m):
		print(1, end='')
	print()
else:
	for i in a:
		l[i - 1] += 1
		ar[l[i - 1]] += 1
		if ar[l[i - 1]] == n:
			print('1', end='')
		else:
			print('0', end='')
	print()


import sys
nm = list(map(int, input().split(' ')))
ms = list(map(int, input().split(' ')))
n = nm[0]
m = nm[1]
counter = [0] * m
diff = [0] * n
times = 0
for mi in ms:
	diff[mi - 1] += 1
	counter[diff[mi - 1] - 1] += 1
	if counter[diff[mi - 1] - 1] % n == 0:
		times += 1
		sys.stdout.write('1')
	else:
		sys.stdout.write('0')


(diff, prob) = [int(x) for x in input().split()]
probs = [int(x) for x in input().split()]
counts = {}
comp = {}
num = 0
for i in range(diff):
	counts[i + 1] = 0
	comp[i + 1] = False
for p in probs:
	counts[p] += 1
	if comp[p] == False:
		num += 1
		comp[p] = True
		if num == diff:
			num = 0
			for i in range(diff):
				counts[i + 1] -= 1
				if counts[i + 1] == 0:
					comp[i + 1] = False
				else:
					num += 1
			print('1', end='')
		else:
			print('0', end='')
	else:
		print('0', end='')
print('')


input = __import__('sys').stdin.readline
print = __import__('sys').stdout.write
(n, m) = map(int, input().split())
diff = map(int, input().split())
tmp = {}
if n > m:
	for _ in range(m):
		print('0')
	print('\n')
else:
	for i in range(n - 1):
		ne = next(diff)
		if ne not in tmp:
			tmp[ne] = 1
		else:
			tmp[ne] += 1
		print('0')
	for i in range(n - 1, m):
		ne = next(diff)
		if ne not in tmp:
			tmp[ne] = 1
		else:
			tmp[ne] += 1
		if len(tmp.keys()) == n:
			print('1')
			for t in list(tmp.keys()):
				if tmp[t] == 1:
					del tmp[t]
				else:
					tmp[t] -= 1
		else:
			print('0')
	print('\n')


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
total = [0] * 10000007
arr = [0] * (n + 1)
j = 1
for i in range(m):
	arr[l[i]] += 1
	total[arr[l[i]]] += 1
	if total[j] == n:
		j += 1
		print(1, end='')
	else:
		print(0, end='')


(a, b) = map(int, input().split())
m = [int(x) for x in input().split()]
s = set()
dif = {}
res = ''
for i in m:
	if i in s:
		if i in dif:
			dif[i] += 1
		else:
			dif[i] = 1
	else:
		s.add(i)
	if len(s) == a:
		res += '1'
		s.clear()
		for i in dif:
			s.add(i)
			dif[i] -= 1
		for i in s:
			if dif[i] == 0:
				del dif[i]
	else:
		res += '0'
print(res)


def solution():
	from sys import stdout, stdin
	(_input, _print) = (stdin.readline, stdout.write)
	(_int, _range, _min, _max) = (int, range, min, max)
	(n, m) = [int(i) for i in input().split()]
	arr = [int(i) for i in input().split()]
	c = [0] * (n + 1)
	ans = [0] * (m + 1)
	for i in arr:
		c[i] += 1
		ans[c[i]] += 1
		if ans[c[i]] == n:
			print('1', end='')
		else:
			print('0', end='')
	print()
solution()


(n, m) = map(int, input().split(' '))
l = list(map(int, input().split(' ')))
d = {}
for i in range(1, n + 1):
	d[i] = [0, []]
mn = 10 ** 5 + 1
if m < n:
	x = ['0'] * m
	print(''.join(x))
else:
	for i in range(0, m):
		try:
			d[l[i]][0] += 1
			d[l[i]][1].append(i)
		except Exception as e:
			d[l[i]] = [1, [i]]
	x = ['0'] * m
	for i in range(1, n + 1):
		if d[i][0] == 0:
			print(''.join(x))
			exit(0)
	keys = list(d.keys())
	for i in keys:
		mn = min(mn, d[i][0])
	for i in range(0, mn):
		mx = -1
		for j in range(0, len(keys)):
			mx = max(d[keys[j]][1][i], mx)
		x[mx] = '1'
	print(''.join(x))


def solve(unique, total, questions):
	table = {}
	index = 0
	setA = set()
	while index < total:
		if questions[index] not in setA:
			setA.add(questions[index])
			table[questions[index]] = 1
		else:
			table[questions[index]] += 1
		if len(setA) == unique:
			print(1, end='')
			for items in table.keys():
				if table[items] > 0:
					table[items] -= 1
				if table[items] == 0:
					setA.discard(items)
		else:
			print(0, end='')
		index += 1
(u, t) = list(map(int, input().split()))
q = list(map(int, input().split()))
solve(u, t, q)


(n, m) = (int(x) for x in input().split())
zeros_nr = n
problem___nr = [0] * n
problems = (int(x) - 1 for x in input().split())
for problem in problems:
	if problem___nr[problem] == 0:
		zeros_nr -= 1
	problem___nr[problem] += 1
	if zeros_nr == 0:
		for cp in range(n):
			problem___nr[cp] -= 1
			if problem___nr[cp] == 0:
				zeros_nr += 1
		print(1, end='')
	else:
		print(0, end='')


from sys import stdin, stdout, setrecursionlimit
from collections import OrderedDict

class Tail_Recursion_Optimization:

	def __init__(self, RECURSION_LIMIT, STACK_SIZE):
		setrecursionlimit(RECURSION_LIMIT)
		threading.stack_size(STACK_SIZE)
		return None

class SOLVE:

	def solve(self):
		R = stdin.readline
		W = stdout.write
		ans = []
		(n, m) = [int(x) for x in R().split()]
		a = [int(x) for x in R().split()]
		pos = OrderedDict()
		for i in range(n):
			pos[i + 1] = []
		for i in range(m):
			pos[a[i]].append(i)
		min_len = 10 ** 6
		for i in range(n):
			min_len = min(min_len, len(pos[i + 1]))
		ans = ['0' for i in range(m)]
		for i in range(min_len):
			max_pos = 0
			for j in pos:
				max_pos = max(max_pos, pos[j][i])
			ans[max_pos] = '1'
		W(''.join(ans))
		return 0

def main():
	s = SOLVE()
	s.solve()
main()


import collections, atexit, math, sys, bisect
sys.setrecursionlimit(1000000)

def getIntList():
	return list(map(int, input().split()))
try:
	import numpy

	def dprint(*args, **kwargs):
		print(*args, file=sys.stderr)
	dprint('debug mode')
except Exception:

	def dprint(*args, **kwargs):
		pass
inId = 0
outId = 0
if inId > 0:
	dprint('use input', inId)
	sys.stdin = open('input' + str(inId) + '.txt', 'r')
if outId > 0:
	dprint('use output', outId)
	sys.stdout = open('stdout' + str(outId) + '.txt', 'w')
	atexit.register(lambda : sys.stdout.close())
(N, M) = getIntList()
za = getIntList()
cnt = [0 for i in range(111000)]
ext = cnt.copy()
for x in za:
	cnt[x] += 1
	ext[cnt[x]] += 1
	if ext[cnt[x]] == N:
		print(1, end='')
	else:
		print(0, end='')


(n, m) = (int(s) for s in input().split(' '))
a = [int(s) for s in input().split(' ')]
probs = {}
for i in a:
	if i in probs:
		probs[i] += 1
		print('0', end='')
	else:
		probs[i] = 1
		if len(probs) == n:
			print('1', end='')
			probs = {k: v - 1 for (k, v) in probs.items() if v > 1}
		else:
			print('0', end='')
print()


import sys
from collections import defaultdict as dd
input = sys.stdin.readline
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
l1 = []
d = dd(int)
s = set([])
for i in range(k):
	d[l[i]] += 1
	l1 = s.add(l[i])
	if len(s) < n:
		print('0', end='')
	else:
		print('1', end='')
		f = list(s)
		for j in f:
			d[j] -= 1
			if d[j] == 0:
				s.remove(j)
print()


def solve(n, m, A):
	res = ['0'] * m
	li = {}
	cnt = 0
	for i in range(m):
		if A[i] not in li:
			li[A[i]] = 1
			cnt += 1
		else:
			if li[A[i]] == 0:
				cnt += 1
			li[A[i]] += 1
		if cnt == n:
			res[i] = '1'
			cnt2 = 0
			for key in li.keys():
				li[key] -= 1
				if li[key] == 0:
					cnt2 += 1
			cnt = n - cnt2
	return res
(n, m) = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = solve(n, m, A)
print(''.join(ans))


from sys import stdin, stdout
from math import gcd, sqrt
from collections import deque
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
P = lambda x: stdout.write(x)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 1 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
N = 10 ** 6 + 7

def hold():
	global dst
	for i in range(n):
		v[i] -= 1
		if not v[i]:
			dst -= 1
(n, m) = R()
v = [0] * n
dst = 0
for i in R():
	if v[i - 1] == 0:
		dst += 1
	v[i - 1] += 1
	if dst == n:
		hold()
		P('1')
	else:
		P('0')


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
a = []
d = {}
s = ''
for i in arr:
	if i not in d:
		d[i] = 1
		a.append(i)
	else:
		d[i] += 1
	if len(d) == n:
		s += '1'
		for j in range(1, n + 1):
			d[j] -= 1
			if d[j] == 0:
				d.pop(j)
	else:
		s += '0'
print(s)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
s = set(range(1, n + 1))
d = {i: 0 for i in range(1, n + 1)}
res = ''
for i in range(m):
	if a[i] not in s:
		d[a[i]] += 1
		res = res + '0'
	else:
		s.remove(a[i])
		if len(s) == 0:
			res = res + '1'
			s = set(range(1, n + 1))
			for z in range(1, n + 1):
				if z in d:
					if d[z] > 0:
						d[z] = d[z] - 1
						s.remove(z)
		else:
			res = res + '0'
print(res)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
kol = n
li = [0 for i in range(n)]
s = ''
for i in arr:
	if li[i - 1] == 0:
		kol -= 1
	li[i - 1] += 1
	if kol == 0:
		s += '1'
		for j in range(n):
			li[j] -= 1
		if '0' in str(li):
			kol = li.count(0)
		else:
			kol = n
	else:
		s += '0'
print(s)


import heapq
from collections import Counter
import random

class PriorityQueue:

	def __init__(self) -> None:
		self._q = []

	def add(self, priority, elem):
		heapq.heappush(self._q, (priority, elem))

	def pop(self):
		(priority, elem) = heapq.heappop(self._q)
		return (priority, elem)

class MySet:

	def __init__(self, n):
		self._n = n
		self._d = Counter()
		self._q = PriorityQueue()
		for i in range(n):
			self._q.add(0, i + 1)

	def add_elem(self, elem):
		self._d[elem] += 1
		self._q.add(self._d[elem], elem)

	def get_min_distinct_count(self):
		while True:
			(priority, elem) = self._q.pop()
			if self._d[elem] > priority:
				continue
			else:
				self._q.add(priority, elem)
				return priority

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

def solve(difficulties, n):
	res = []
	cur_min_count = 1
	s = MySet(n)
	for d in difficulties:
		s.add_elem(d)
		min_distinct_count = s.get_min_distinct_count()
		if min_distinct_count == cur_min_count:
			res.append('1')
			cur_min_count += 1
		else:
			res.append('0')
	print(''.join(res))

def main():
	(n, _) = read_nums()
	difficulties = read_nums()
	solve(difficulties, n)
main()


(n, k) = tuple(map(int, input().split()))
arr = list(map(int, input().split()))
count = [0] * (n + 1)
ans = []
count_of_zeros = n
for a in arr:
	if count[a] == 0:
		count_of_zeros -= 1
	count[a] += 1
	if count_of_zeros == 0:
		for i in range(n):
			if count[i + 1] == 1:
				count_of_zeros += 1
			count[i + 1] -= 1
		ans.append('1')
	else:
		ans.append('0')
print(''.join(ans))


(n, m) = map(int, input().split())
mass = list(map(int, input().split()))
wuneed = set()
for i in range(1, n + 1):
	wuneed.add(i)
bank = dict()
for tutu in mass:
	wuneed.discard(tutu)
	if tutu in bank:
		bank[tutu] += 1
	else:
		bank[tutu] = 1
	if wuneed == set():
		print('1', end='')
		for t in bank:
			bank[t] -= 1
			if bank[t] == 0:
				wuneed.add(t)
	else:
		print('0', end='')


from operator import itemgetter
from math import log, ceil
(n, m) = map(int, input().split())
ai = list(map(int, input().split()))
num = ceil(log(n, 2)) + 2
ai3 = [[0] * 2 ** i for i in range(num)]
num2 = 2 ** (num - 1)
for i in range(n, num2):
	ai3[-1][i] = 100001
for j in range(num - 2, -1, -1):
	for i in range(len(ai3[j])):
		ai3[j][i] = min(ai3[j + 1][i * 2], ai3[j + 1][i * 2 + 1])
cur = 1
for i in ai:
	ai3[-1][i - 1] += 1
	i -= 1
	for j in range(num - 2, -1, -1):
		i //= 2
		ai3[j][i] = min(ai3[j + 1][i * 2], ai3[j + 1][i * 2 + 1])
	if ai3[0][0] == cur:
		cur += 1
		print(1, end='')
	else:
		print(0, end='')


(n, m) = list(map(int, input().split(' ')))
a_list = [int(elm) - 1 for elm in input().split(' ')]
counts = [0] * n
val_counts = [0] * (m + 1)
out_txt = ''
cond = 1
for a in a_list:
	counts[a] += 1
	val_counts[counts[a]] += 1
	if val_counts[cond] == n:
		flag = True
		cond += 1
	else:
		flag = False
	if flag:
		out_txt += '1'
	else:
		out_txt += '0'
print(out_txt)


a = input().split(' ')
c = dict()
b = input().split(' ')
aux = dict()
r = 0
zeros = 0
for x in range(1, int(a[0]) + 1):
	aux[x] = 0
	zeros += 1
for x in b:
	int_x = int(x)
	if aux[int_x] == 0:
		zeros -= 1
	aux[int_x] += 1
	if zeros > 0:
		c[r] = 0
		r += 1
	else:
		c[r] = 1
		for h in aux:
			aux[h] -= 1
			if aux[h] == 0:
				zeros += 1
		r += 1
i = 0
while i < r:
	print(c[i], end='')
	i += 1


(n, m) = input().split()
n = int(n)
m = int(m)
counter = 1
x = input().split()
x = list(map(int, x))
arr = [0] * (m + 1)
count = [0] * n
for i in x:
	count[i - 1] += 1
	arr[count[i - 1]] += 1
	if arr[counter] == n:
		print(1, end='')
		counter += 1
		continue
	print(0, end='')
print()


nm = list(map(int, input().split()))
n = nm[0]
lst = list(map(int, input().split()))
s = set()
result = ''
dct = {}
for i in lst:
	x = len(s)
	s.add(i)
	if x == len(s):
		dct[i] = dct.get(i, 0) + 1
		result = result + '0'
	elif len(s) == n:
		result = result + '1'
		s = set(dct.keys())
		for i in s:
			dct[i] -= 1
			if dct[i] == 0:
				dct.pop(i)
	else:
		result = result + '0'
print(result)


import sys
inf = float('inf')
mod = 1000000007

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

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

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

def main():
	(n, m) = get_ints()
	arr = get_array()
	d = {}
	s = set()
	ans = [0] * m
	for i in range(m):
		x = arr[i]
		if x not in d:
			d[x] = 0
		d[x] += 1
		s.add(x)
		if len(s) == n:
			ans[i] = 1
			for i in range(1, n + 1):
				d[i] -= 1
				if d[i] == 0:
					s.remove(i)
		else:
			ans[i] = 0
	print(*ans, sep='')
main()


(n, m) = map(int, input().split())
l1 = list(map(int, input().split()))
ans = ''
d1 = {}
d2 = {}
count = 0
for item in l1:
	if item not in d1:
		d2[item] = 1
		d1[item] = 1
	else:
		if item in d2:
			del d2[item]
		d1[item] += 1
	if len(d1) == n:
		ans = ans + '1'
		for k in d2:
			del d1[k]
		d2 = {}
		for k in d1:
			d1[k] -= 1
			if d1[k] == 1:
				d2[k] = 1
	else:
		ans = ans + '0'
print(ans)


(n, m) = map(int, input().split())
a = []
a = list(map(int, input().split()))
count = 0
z = dict()
for i in range(1, n + 1):
	z[i] = 0
for i in range(0, m):
	if z[a[i]]:
		z[a[i]] += 1
	else:
		z[a[i]] += 1
		count += 1
	if count == n:
		count = 0
		print('1', end='')
		for j in range(1, n + 1):
			z[j] -= 1
			if z[j]:
				count += 1
	else:
		print('0', end='')


(n, m) = map(int, input().split())
d = dict()
a = map(int, input().split())
ans = []
for x in a:
	d[x] = d.get(x, 0) + 1
	if len(d) == n:
		for i in range(1, n + 1):
			d[i] -= 1
			if d[i] == 0:
				d.pop(i)
		ans.append('1')
	else:
		ans.append('0')
print(''.join(ans))


X = list(map(int, input().split()))
Problems = list(map(int, input().split()))
Number = [0] * (X[0] + 1)
Check = [0] * (X[1] + 1)
for i in Problems:
	Number[i] += 1
	Check[Number[i]] += 1
	if Check[Number[i]] == X[0]:
		print(1, end='')
	else:
		print(0, end='')


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
a = [0 for i in range(n)]
summ = [0 for i in range(m)]
j = 0
for i in l:
	a[i - 1] += 1
	z = a[i - 1] - 1 - j
	summ[z] += i
	if summ[0] == int(n * (n + 1) / 2):
		j += 1
		summ.pop(0)
		print(1, end='')
	else:
		print(0, end='')
print()


(n, m) = map(int, input().split())
a = list(map(lambda x: int(x) - 1, input().split()))
rec = [0] * n
dic = {}
for i in range(m):
	rec[a[i]] += 1
	dic[rec[a[i]]] = i
mi = min(rec)
ans = ['0'] * m
for i in range(1, mi + 1):
	ans[dic[i]] = '1'
print(''.join(ans))


(j, k) = input().split()
j = int(j)
k = int(k)
l = list(map(int, input().split()))
d = {}
a = []
for i in l:
	if i not in d:
		d[i] = 1
	else:
		d[i] += 1
	if len(d) == j:
		a.append(1)
		for _ in range(1, j + 1):
			if d[_] > 1:
				d[_] -= 1
			else:
				del d[_]
		continue
	a.append(0)
print(*a, sep='')


(n, m) = [int(x) for x in input().split()]
ans = ['0'] * m
a = [int(x) for x in input().split()]
di = {}
count = 0
for i in range(m):
	if a[i] not in di:
		di[a[i]] = 1
		count += 1
	else:
		if di[a[i]] == 0:
			count += 1
		di[a[i]] += 1
	if count == n:
		ans[i] = '1'
		c = 0
		for key in di.keys():
			di[key] -= 1
			if di[key] == 0:
				c += 1
		count = n - c
print(''.join(ans))


from collections import deque
(m, n) = list(map(int, input().split()))
q = list(map(int, input().split()))
current_contest = set([])
frequencies = {}
out = ''
for i in q:
	if i not in frequencies:
		frequencies[i] = 0
for i in range(len(q)):
	if frequencies[q[i]] == 0:
		frequencies[q[i]] += 1
		current_contest.add(q[i])
		if len(current_contest) == m:
			out += '1'
			for (k, v) in frequencies.items():
				if v == 1:
					current_contest.remove(k)
				frequencies[k] -= 1
		else:
			out += '0'
	else:
		out += '0'
		frequencies[q[i]] += 1
print(out)


from sys import stdin
(n, m) = list(map(int, stdin.readline().split()))
arr = list(map(int, stdin.readline().split()))
mydict = dict()
myset = set()
for i in range(1, n + 1):
	mydict[i] = 0
for i in range(m):
	mydict[arr[i]] += 1
	myset.add(arr[i])
	if len(myset) == n:
		for j in mydict:
			if mydict[j] - 1 == 0:
				myset.remove(j)
			if mydict[j] >= 1:
				mydict[j] -= 1
		print(1, end='')
	else:
		print(0, end='')


import collections
(n, m) = map(int, input().split())
a = map(int, input().split())
unique = collections.Counter({x: 1 for x in range(1, n + 1)})
counter = collections.Counter()
result = ['0'] * m
for (i, val) in enumerate(a):
	counter[val] += 1
	if len(counter) == n:
		counter -= unique
		result[i] = '1'
print(''.join(result))


maxn = 100000 + 7
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = [None] * maxn
st = set()

def dele(n):
	for i in range(1, n + 1):
		b[i] -= 1

def update(n):
	st.clear()
	for i in range(1, n + 1):
		if b[i] > 0:
			st.add(i)
for i in range(maxn):
	b[i] = 0
for i in a:
	b[i] += 1
	st.add(i)
	if len(st) == n:
		print(1, end='')
		dele(n)
		update(n)
	else:
		print(0, end='')


(n, m) = list(map(int, input().split()))
arr = list(map(int, input().split()))
am = 0
have = [0] * n
out = [0] * m
for i in range(m):
	if have[arr[i] - 1] == 0:
		am += 1
	have[arr[i] - 1] += 1
	if am == n:
		out[i] = 1
		am = 0
		for g in range(n):
			have[g] -= 1
			if have[g]:
				am += 1
print(*out, sep='')


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
coun = [0] * n
numb = [0] * (m + 1)
numb[0] = n
hold = 0
ans = ''
for i in range(m):
	x = a[i] - 1
	numb[coun[x]] -= 1
	coun[x] += 1
	numb[coun[x]] += 1
	if numb[hold] == 0:
		ans += '1'
		hold += 1
	else:
		ans += '0'
print(ans)


(n, m) = map(int, input().split())
li = list(map(int, input().split()))
pool = [[] for i in range(n)]
for i in range(m):
	pool[li[i] - 1].append(i + 1)
(a, b) = (1, 1)
for i in range(min([len(x) for x in pool])):
	a = max([x.pop(0) for x in pool])
	print('0' * (a - b) + '1', end='')
	b = a + 1
print('0' * (m - b + 1))


def solve():
	out_arr = []
	for i in range(0, len(ll)):
		if is_complete(i):
			out_arr.append('1')
		else:
			out_arr.append('0')
	return ''.join(out_arr)

def is_complete(index):
	global current_round
	count_arr[ll[index]] += 1
	round_arr[count_arr[ll[index]]] += 1
	if round_arr[current_round] == n:
		current_round += 1
		return True
	else:
		return False
arr = [int(x) for x in input().split()]
n = arr[0]
m = arr[1]
max_rounds = int(m / n)
current_round = 1
ll = [int(x) for x in input().split()]
count_arr = [0] * (n + 1)
round_arr = [0] * (m + 1)
print(solve())


import math
import bisect
import itertools
import sys
I = lambda : sys.stdin.readline()
mod = 10 ** 9 + 7

def mindiff(a):
	b = a[:]
	b.sort()
	m = 10000000000
	for i in range(len(b) - 1):
		if b[i + 1] - b[i] < m:
			m = b[i + 1] - b[i]
	return m

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

def merge(a, b):
	i = 0
	j = 0
	c = 0
	ans = []
	while i < len(a) and j < len(b):
		if a[i] < b[j]:
			ans.append(a[i])
			i += 1
		else:
			ans.append(b[j])
			c += len(a) - i
			j += 1
	ans += a[i:]
	ans += b[j:]
	return (ans, c)

def mergesort(a):
	if len(a) == 1:
		return (a, 0)
	mid = len(a) // 2
	(left, left_inversion) = mergesort(a[:mid])
	(right, right_inversion) = mergesort(a[mid:])
	(m, c) = merge(left, right)
	c += left_inversion + right_inversion
	return (m, c)

def is_prime(num):
	if num == 1:
		return False
	if num == 2:
		return True
	if num == 3:
		return True
	if num % 2 == 0:
		return False
	if num % 3 == 0:
		return False
	t = 5
	a = 2
	while t <= int(math.sqrt(num)):
		if num % t == 0:
			return False
		t += a
		a = 6 - a
	return True

def ceil(a, b):
	if a % b == 0:
		return a // b
	else:
		return a // b + 1

def binsearch(arr, b, low, high):
	if low == high:
		return low
	if arr[math.ceil((low + high) / 2)] < b:
		return binsearch(arr, b, low, math.ceil((low + high) / 2) - 1)
	else:
		return binsearch(arr, b, math.ceil((low + high) / 2), high)

def ncr1(n, r):
	s = 1
	for i in range(min(n - r, r)):
		s *= n - i
		s %= mod
		s *= pow(i + 1, mod - 2, mod)
		s %= mod
	return s

def calc(n, m, r):
	s = 0
	for i in range(0, r + 1, 2):
		s += ncr1(n, i) * ncr1(m, i)
		s %= mod
	return s
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
d = {}
for i in range(k):
	d[a[i]] = d.get(a[i], 0) + 1
	if len(d) == n:
		p = []
		print('1', end='')
		for j in d:
			if d[j] == 1:
				p.append(j)
			else:
				d[j] -= 1
		for j in p:
			del d[j]
	else:
		print('0', end='')


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
probs = {}
for i in range(1, n + 1):
	probs[i] = 0
soma = 0
for i in a:
	if probs[i] == 0:
		soma += 1
		probs[i] = 1
		if soma == n:
			print('1', end='')
			for j in range(1, n + 1):
				probs[j] -= 1
				if probs[j] == 0:
					soma -= 1
		else:
			print('0', end='')
	else:
		probs[i] += 1
		print('0', end='')


from heapq import heappush, heappop
from collections import defaultdict
(num_difs, num_probs) = [int(x) for x in input().split()]
probs = [int(x) - 1 for x in input().split()]

def root_not_uptodate(heap):
	(val, idx) = heap[0]
	return dif_counts[idx] != val
is_round = [False for _ in range(num_probs)]
heap = [(0, idx) for idx in range(num_difs)]
dif_counts = defaultdict(int)
num_held = 0
for (i, dif) in enumerate(probs):
	dif_counts[dif] += 1
	heappush(heap, (dif_counts[dif], dif))
	while heap and root_not_uptodate(heap):
		heappop(heap)
	if heap and heap[0][0] - num_held > 0:
		num_held += 1
		is_round[i] = True
print(''.join(('1' if is_r else '0' for is_r in is_round)))