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: interview

Starter code:

Solutions:
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='')


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)

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 = [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))


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))


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())
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='')

n, m = (int(x) for x in input().split())
a = [int(x) for x in input().split()]

#print(n, m, a)

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="")

#print(d)

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='')
    
              
    

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)
#print(b)
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 = 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))


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='')

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())
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)        

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="")



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)

def __starting_point():
    main()

__starting_point()

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="")


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)

###### Author : Samir Vyas #######
###### Write Code Below    #######

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 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))


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)))




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
# print(d)
index = 0
while True:
	for i in range(1, n + 1):
		if len(d[i]) < k:
			print(*ans, sep = '')
			return
		index = max(index, d[i][k-1])
	k += 1
	# print(index)
	ans[index] = 1
print(*ans, sep = '')

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())
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()))
b=dict()
for i in range(len(a)):
    b[a[i]]=b.get(a[i],0)
    b[a[i]]+=1
    # print(b)

    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="")


#	!/usr/bin/env python3
#	coding: UTF-8
#	Modified: <13/Jan/2019 08:32:29 PM>


#	✪ H4WK3yE乡
#	Mohd. Farhan Tahir
#	Indian Institute Of Information Technology (IIIT),Gwalior

#	Question Link
#
#

# ///==========Libraries, Constants and Functions=============///


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()

# ///==========MAIN=============///


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='')


def __starting_point():
    main()

__starting_point()