Mashmokh works in a factory. At the end of each day he must turn off all of the lights. 

The lights on the factory are indexed from 1 to n. There are n buttons in Mashmokh's room indexed from 1 to n as well. If Mashmokh pushes button with index i, then each light with index not less than i that is still turned on turns off.

Mashmokh is not very clever. So instead of pushing the first button he pushes some of the buttons randomly each night. He pushed m distinct buttons b_1, b_2, ..., b_{m} (the buttons were pushed consecutively in the given order) this night. Now he wants to know for each light the index of the button that turned this light off. Please note that the index of button b_{i} is actually b_{i}, not i.

Please, help Mashmokh, print these indices.


-----Input-----

The first line of the input contains two space-separated integers n and m (1 ≤ n, m ≤ 100), the number of the factory lights and the pushed buttons respectively. The next line contains m distinct space-separated integers b_1, b_2, ..., b_{m} (1 ≤ b_{i} ≤ n).

It is guaranteed that all lights will be turned off after pushing all buttons.


-----Output-----

Output n space-separated integers where the i-th number is index of the button that turns the i-th light off.


-----Examples-----
Input
5 4
4 3 1 2

Output
1 1 3 4 4 

Input
5 5
5 4 3 2 1

Output
1 2 3 4 5 



-----Note-----

In the first sample, after pressing button number 4, lights 4 and 5 are turned off and lights 1, 2 and 3 are still on. Then after pressing button number 3, light number 3 is turned off as well. Pressing button number 1 turns off lights number 1 and 2 as well so pressing button number 2 in the end has no effect. Thus button number 4 turned lights 4 and 5 off, button number 3 turned light 3 off and button number 1 turned light 1 and 2 off.

Difficulty: EASY

Solutions:
from array import *
from itertools import *
(n, m) = list(map(int, input().split()))
bs = map(int, input().split())
a = array('i', repeat(0, n))
for b in bs:
	for i in range(b - 1, n):
		if a[i] != 0:
			break
		a[i] = b
for i in a:
	print(i, end=' ')


(n, m) = [int(i) for i in input().split(' ')]
arr = [-1] * n
b = [int(i) for i in input().split(' ')]
for i in b:
	for j in range(i - 1, n):
		if arr[j] == -1:
			arr[j] = i
print(' '.join([str(i) for i in arr]))


(n, m) = [int(i) for i in input().split()]
lista = [int(i) - 1 for i in input().split()]
aux = [0] * n
for i in range(m):
	for j in range(lista[i], n):
		if not aux[j]:
			aux[j] = lista[i] + 1
print(*aux)


import sys
import math
import bisect
import itertools
import random

def main():
	(n, m) = map(int, input().split())
	A = [-1] * n
	B = list(map(int, input().split()))
	for i in range(m):
		b = B[i]
		for j in range(b - 1, n):
			if A[j] == -1:
				A[j] = b - 1
	print(' '.join(list((str(a + 1) for a in A))))
main()


from collections import *
(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
ans = [0 for i in range(n + 1)]
m = n + 1
for i in range(k):
	if a[i] >= m:
		continue
	for j in range(a[i], m):
		ans[j] = a[i]
	m = a[i]
for i in ans[1:]:
	print(i, end=' ')
print()


class InputHandlerObject(object):
	inputs = []

	def getInput(self, n=0):
		res = ''
		inputs = self.inputs
		if not inputs:
			inputs.extend(input().split(' '))
		if n == 0:
			res = inputs[:]
			inputs[:] = []
		while n > len(inputs):
			inputs.extend(input().split(' '))
		if n > 0:
			res = inputs[:n]
			inputs[:n] = []
		return res
InputHandler = InputHandlerObject()
g = InputHandler.getInput
(n, m) = g()
(n, m) = (int(n), int(m))
b = g()
a = [0] * n
for i in b:
	for j in range(int(i) - 1, n):
		a[j] = i if a[j] == 0 else a[j]
print(' '.join(a))


R = lambda : map(int, input().split())
(n, m) = R()
arr = list(R())
a = [0] * n
for i in arr:
	a[i - 1:n] = [i] * (n - i + 1)
	n = min(i - 1, n)
print(*a)


(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
ans = [0 for i in range(n + 1)]
for i in a:
	for j in range(i, n + 1):
		if ans[j] == 0:
			ans[j] = i
print(*ans[1:])


(n, m) = tuple(map(int, input().strip().split()))
b = tuple(map(int, input().strip().split()))
res = [0 for _ in range(n)]
for b_i in b:
	for i in range(b_i - 1, n):
		if res[i] == 0:
			res[i] = b_i
print(' '.join(map(str, res)))


(n, m) = map(int, input().split())
buttons = list(map(int, input().split()))
lights = [0] * (n + 1)
for i in buttons:
	for j in range(i, len(lights)):
		if lights[j] == 0:
			lights[j] = i
for i in range(1, len(lights)):
	print(lights[i], end=' ')


(n, m) = map(int, input().split())
b = list(map(int, input().split()))
a = [0] * (n + 1)
minb = n + 1
for x in b:
	if x < minb:
		minb = x
		a[x] = x
v = a[1]
for i in range(2, n + 1):
	if a[i] == 0:
		a[i] = v
	else:
		v = a[i]
print(' '.join(map(str, a[1:])))


(n, m) = str(input()).split()
n = int(n)
m = int(m)
line = str(input()).split()
line = [int(it) for it in line]
note = [0 for it in range(n)]
for it in line:
	for i in range(it - 1, n):
		if note[i] == 0:
			note[i] = it
note = [str(it) for it in note]
print(' '.join(note))


(n, m) = list(map(int, input().split()))
c = [int(i) for i in input().split()]
closed = [False] * n
ans = [0] * n
for i in c:
	if closed[0]:
		break
	for j in range(i - 1, n):
		if not closed[j]:
			closed[j] = True
			ans[j] = i
		else:
			continue
print(' '.join((str(i) for i in ans)))


(n, m) = input().split()
(n, m) = (int(n), int(m))
lis = input().split()
for i in range(len(lis)):
	lis[i] = int(lis[i])
dic = {}
for i in range(1, n + 1):
	dic[i] = []
for i in range(m):
	for j in range(lis[i], n + 1):
		dic[j].append(lis[i])
for i in range(1, n + 1):
	print(dic[i][0], end=' ')


import sys
line = str.split(input(), ' ')
n = int(line[0])
m = int(line[1])
pushed = [int(i) for i in str.split(input(), ' ')]
buttons = [0 for i in range(n)]

def pushButton(buttons, bi):
	for i in range(bi - 1, len(buttons)):
		if buttons[i] == 0:
			buttons[i] = bi
	return buttons
for bi in pushed:
	buttons = pushButton(buttons, bi)
for x in buttons[0:-1]:
	sys.stdout.write(str(x) + ' ')
sys.stdout.write(str(buttons[len(buttons) - 1]))


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = []
for i in range(102):
	b.append(0)
for i in a:
	if b[i] == 0:
		j = i
		while 1 and j < 101:
			if b[j] != 0:
				break
			else:
				b[j] = i
				j += 1
for i in range(1, n + 1):
	print(b[i], end=' ')


import sys
input = sys.stdin.readline

def gint():
	return int(input())

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

def gfloat():
	return float(input())

def gfloat_arr():
	return list(map(float, input().split()))

def pair_int():
	return map(int, input().split())
INF = 1 << 31
MOD = '1000000007'
dx = [-1, 0, 1, 0]
dy = [0, 1, 0, -1]
(n, m) = gint_arr()
a = gint_arr()
res = [-1] * (n + 1)
for b in a:
	x = b
	while x <= n:
		if res[x] == -1:
			res[x] = b
		x += 1
for i in range(1, n + 1):
	print(res[i], end=' ')


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


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


(n, m) = map(int, input().split())
light = list(map(int, input().split()))
ans = n * [0]
for i in light:
	temp = i
	while temp < n and ans[temp - 1] == 0:
		ans[temp - 1] = i
		temp = temp + 1
ans.remove(ans[-1])
ans.append(light[0])
print(*ans, sep=' ')


(n, m) = map(int, input().split())
b = list(map(int, input().split()))
x = [1] * (n + 1)
ans = [0] * (n + 1)
for i in range(m):
	for k in range(b[i], n + 1):
		if x[k] == 1:
			ans[k] = b[i]
		x[k] = 0
print(*ans[1:])


import sys
[n, m] = map(int, sys.stdin.readline().split())
lamps = [0 for x in range(n + 1)]
buttons = map(int, sys.stdin.readline().split())
for b in buttons:
	for i in range(b, n + 1):
		if not lamps[i]:
			lamps[i] = b
print(' '.join(map(str, lamps[1:])))


import itertools

def main():
	(n, m) = [int(v) for v in input().split()]
	data = [int(v) for v in input().split()]
	res = [-1 for i in range(n)]
	for (i, v) in enumerate(data):
		for j in range(v, n + 1):
			if res[j - 1] == -1:
				res[j - 1] = v
	print(' '.join([str(d) for d in res]))
main()


(n, m) = map(int, input().split())
b = list(map(int, input().split()))
ans = [-1] * 101
for bb in b:
	for i in range(bb, n + 1):
		if ans[i] == -1:
			ans[i] = bb
		else:
			break
print(*ans[1:n + 1])


s = [int(i) for i in input().split(' ')]
N = int(s[0])
M = int(s[1])
button = [int(i) for i in input().split(' ')]
A = [0 for i in range(N)]
for i in range(N):
	for j in range(M):
		if button[j] <= i + 1:
			A[i] = button[j]
			break
print(*A, sep=' ')


(N, M) = list(map(int, input().split()))
arraybi = list(map(int, input().split()))
arraylamp = list(range(1, N + 1))
num = 0
array = ''
for lamp in arraylamp:
	while arraybi[num] > lamp:
		num += 1
	array += str(arraybi[num]) + ' '
	num = 0
print(array)


s1 = input()
s = s1.split()
n = int(s[0])
m = int(s[1])
b1 = input()
b = b1.split()
a = []
for i in range(n):
	a.append('0')
for i in range(m):
	x = int(b[i])
	for j in range(x - 1, n):
		if a[j] == '0':
			a[j] = b[i]
for i in range(n):
	print(a[i], end=' ')


dic = {}
list = [int(x) for x in input().split(' ')]
list_1 = [int(x) for x in input().split(' ')]
for num in list_1:
	dic[num] = [int(i) for i in range(num, list[0] + 1)]
val = 1
while val < list[0] + 1:
	for key in dic:
		if val in dic[key]:
			print(key, end=' ')
			val += 1
			break


(n, m) = map(int, input().split())
l = list(map(int, input().split(' ')))
l = l[::-1]
j = []
for i in range(n):
	j.append(' ')
for i in l:
	for k in range(i, n + 1):
		j[k - 1] = i
print(' '.join(map(str, j)))


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_intList_from_str = lambda : list(map(int, list(sys.stdin.readline().strip())))
get_charList_from_str = lambda : list(sys.stdin.readline().strip())
get_char_list = lambda : sys.stdin.readline().strip().split()
get_int = lambda : int(sys.stdin.readline())
pt = lambda x: sys.stdout.write(str(x))
(n, m) = get_int_list()
lst = get_int_list()
ans = [0] * n
for i in lst:
	for j in range(i - 1, n):
		if ans[j] == 0:
			ans[j] = i
print(*ans)


string = input()
numbers = string.split()
(a, b) = (int(numbers[0]), int(numbers[1]))
string = input()
buttons = list(map(int, string.split()))
lights = [0 for x in range(a)]
for x in buttons:
	for y in range(x - 1, a):
		if lights[y] == 0:
			lights[y] = x
print(' '.join(map(str, lights)))


(x, y) = map(int, input().split())
z = [int(x) for x in input().split()]
x = x + 1
for i in range(1, x):
	for m in range(y):
		if i >= z[m]:
			print(z[m], end=' ')
			break
	continue


(n, m) = (int(x) for x in input().split())
l = [0] * n
for b in (int(x) for x in input().split()):
	for i in range(b - 1, n):
		if l[i] == 0:
			l[i] = b
print(' '.join(map(str, l)))


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
ans = [-1] * 101
for i in arr:
	for j in range(i, n + 1):
		if ans[j] == -1:
			ans[j] = i
print(*ans[1:n + 1])


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
z = [0] * (n + 1)
for i in x:
	j = i
	while j < n + 1 and z[j] == 0:
		z[j] = i
		j += 1
for i in range(1, n + 1):
	print(z[i], end=' ')


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
emp = []
im = []
for i in l:
	for j in range(i, n + 1):
		if j not in emp:
			emp.append(j)
			im.append((j, i))
im.sort()
for ele in im:
	print(ele[1], end=' ')


import sys
import math
(n, m) = [int(x) for x in sys.stdin.readline().split()]
b = [int(x) for x in sys.stdin.readline().split()]
res = []
v = n
for k in b:
	while v >= k:
		res.append(str(k))
		v -= 1
print(' '.join(res[::-1]))


def main():
	[n, m] = [int(_) for _ in input().split()]
	buttons = [int(_) for _ in input().split()]
	lights = [0] * (n + 1)
	for button in buttons:
		i = button
		while i <= n and lights[i] == 0:
			lights[i] = button
			i += 1
	result = ' '.join([str(lights[i]) for i in range(1, n + 1)])
	print(result)
main()


(n, m) = map(int, input().split())
b = map(int, input().split())
light = []
setlight = set()
for i in b:
	if i not in setlight:
		for j in range(i, n + 1):
			if j not in setlight:
				light.append(i)
				setlight.add(j)
print(*sorted(light))


(n, m) = list(map(int, input().split()))
y = [0] * n
t = list(map(int, input().split()))
for j in t:
	for k in range(j - 1, len(y)):
		if y[k] == 0:
			y[k] = j
print(*y)


x = input()
l = x.split(' ')
arr = []
for i in range(1000):
	arr.append(0)
n = int(l[0])
m = int(l[1])
t = input()
ll = t.split(' ')
for i in range(m):
	for j in range(int(ll[i]), n + 1):
		if arr[j] == 0:
			arr[j] = int(ll[i])
for i in range(1, n + 1):
	print(arr[i], end=' ')


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
ans = [None] * n
for i in a:
	for j in range(i - 1, len(ans)):
		if ans[j] == None:
			ans[j] = i
for k in ans:
	print(k, end=' ')


(n, m) = list(map(int, input().split()))
our_list = list(map(int, input().split()))
our_list_2 = []
for i in range(n + 1):
	our_list_2.append(0)
for i in range(m):
	for j in range(our_list[i], n + 1):
		if our_list_2[j] == 0:
			our_list_2[j] = our_list[i]
print(' '.join(list(map(str, our_list_2[1:]))))


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


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
x = [0 for i in range(n)]
for i in range(m):
	for j in range(l[i] - 1, n):
		if x[j] == 0:
			x[j] = l[i]
print(*x)


(n, m) = [int(c) for c in input().split()]
turns = [int(c) for c in input().split()]
lamps = [0] * n
for i in range(m):
	t = turns[i]
	it = t - 1
	while it < n and lamps[it] == 0:
		lamps[it] = t
		it += 1
print(' '.join(map(str, lamps)))


(a, b) = map(int, input().split())
c = [0] * a
for i in map(int, input().split()):
	c[i - 1:a] = [i] * (a - i + 1)
	a = min(i - 1, a)
print(*c)


def solve(n, m, b):
	a = [-1 for _ in range(n)]
	for (i, k) in enumerate(b):
		for j in range(k - 1, n):
			if a[j] == -1:
				a[j] = k
	return ' '.join(map(str, a))

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


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
ans = [a[0]] * (n - a[0] + 1)
for i in a[1:]:
	if i < ans[0]:
		ans = [i] * (n - len(ans) - i + 1) + ans
print(*ans)


(n, b) = [int(x) for x in input().split()]
lights_order = [int(x) for x in input().split()]
prev_light = n
arr = [n] * n
for light in lights_order:
	if light < prev_light + 1:
		arr[light - 1:prev_light] = [light] * (prev_light - light + 1)
		prev_light = light - 1
	if light == 1:
		break
print(*arr)


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


(n, m) = map(int, input().split())
d = list(map(int, input().split()))
ans = [0] * 101
for i in range(m):
	x = d[i]
	for j in range(x, n + 1):
		if ans[j] == 0:
			ans[j] = x
		else:
			break
print(*ans[1:n + 1])


(n, m) = map(int, input().split())
b = list(map(int, input().split()))
ans = [0] * n
pos = n + 1
for i in range(m):
	for j in range(b[i], pos):
		ans[j - 1] = b[i]
		pos = b[i]
print(' '.join((str(ans[i]) for i in range(n))))


R = lambda : map(int, input().split())
(n, m) = R()
a = [0] * n
b = list(R())
for i in range(m):
	for j in range(b[i] - 1, n):
		if a[j] == 0:
			a[j] = b[i]
		else:
			break
print(' '.join(map(str, a)))


import sys
(n, m) = map(int, sys.stdin.readline().split())
buttons = map(int, sys.stdin.readline().split())
lights = [-1 for i in range(n)]
for b in buttons:
	for bi in range(b - 1, n):
		if lights[bi] < 0:
			lights[bi] = b
print(' '.join(map(str, lights)))


(n, m) = map(int, input().split())
b = list(map(int, input().split()))
a = list()
a.append(b[0])
temp = b[0]
for i in range(m - 1):
	if temp > b[i + 1]:
		a.append(b[i + 1])
		temp = b[i + 1]
a = a[::-1]
for i in range(len(a) - 1):
	for _ in range(a[i + 1] - a[i]):
		print(str(a[i]), end=' ')
for _ in range(n - a[len(a) - 1] + 1):
	print(a[len(a) - 1], end=' ')


import math
import random
import time

def __starting_point():
	room = input().split(' ')
	b = input().split(' ')
	res = [0 for i in range(int(room[0]))]
	for i in range(int(room[1])):
		for num in range(int(b[i]) - 1, int(room[0])):
			if res[num] == 0:
				res[num] = int(b[i])
	for i in range(len(res)):
		print(repr(res[i]) + ' ', end='')
__starting_point()


def main():
	(n, m) = map(int, input().split())
	seq = list(map(int, input().split()))
	ans = {}
	for e in seq:
		for i in range(e, n + 1):
			if i not in ans:
				ans[i] = e
	out = []
	for i in range(1, n + 1):
		out.append(ans[i])
	print(*out)
main()


(n, m) = map(int, input().split())
q = list(map(int, input().split()))
e = [0] * n
for i in range(0, len(q)):
	j = q[i] - 1
	while j < len(e) and e[j] == 0:
		e[j] = q[i]
		j += 1
print(*e)


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


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


(n, m) = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
v = [-1] * n
for i in range(m):
	z = b[i] - 1
	for j in range(z, n):
		if v[j] == -1:
			v[j] = z + 1
for i in v:
	print(i, end=' ')


(n, m) = map(int, input().split())
l = []
f = []
for j in range(n):
	l.append(1)
b = list(map(int, input().split()))
for i in b:
	for j in range(i - 1, n):
		l[j] = 0
		f.append(i)
		n = n - 1
f.sort()
print(*f, sep=' ')


(n, m) = map(int, input().split())
a = [int(x) for x in input().split()]
lst = [0] * (n + 1)
for i in a:
	for j in range(i, n + 1):
		if lst[j] == 0:
			lst[j] = i
		else:
			break
print(*lst[1:])


(a, b) = map(int, input().split())
l = list(map(int, input().split()))
k = b + 1
for i in range(a):
	for j in range(b):
		if l[j] <= i + 1:
			print(l[j], end=' ')
			break


(n, m) = list(map(int, input().split()))
out = [-1] * n
bulbs = list(map(int, input().split()))
for i in bulbs:
	j = i - 1
	while j < n and out[j] == -1:
		out[j] = str(i)
		j += 1
print(' '.join(out))


__author__ = 'Lipen'

def main():
	(n, m) = map(int, input().split())
	b = list(map(int, input().split()))
	answer = [0] * n
	for x in b:
		for w in range(x - 1, n):
			if answer[w] == 0:
				answer[w] = x
	s = ''
	for x in answer:
		s += str(x) + ' '
	print(s[:-1])
main()


def main():
	(n, m) = map(int, input().split())
	l = [0] * n
	for b in map(int, input().split()):
		for j in range(b - 1, n):
			l[j] = b
		if n >= b:
			n = b - 1
	print(*l)
main()


(n, m) = map(int, input().split())
buttons_pressed = list(map(int, input().split()))
for i in range(1, n + 1):
	for button in buttons_pressed:
		if button <= i:
			print(button, end=' ')
			break


import sys

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

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

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

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
(n, m) = rinput()
a = list(map(int, input().split()))
b = [0] * n
for i in range(m):
	for j in range(a[i] - 1, n):
		if b[j] == 0:
			b[j] = a[i]
print(*b)


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


(n, m) = map(int, input().split())
L = list(map(int, input().split()))
Q = [1] * n
Ans = [-1] * n
for i in range(m):
	x = L[i] - 1
	for j in range(x, n):
		if Q[j] == 1:
			Q[j] = 0
			Ans[j] = x + 1
for item in Ans:
	print(item, end=' ')


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
r = [[True] for _ in range(n)]
for i in l:
	for j in range(i - 1, n):
		if r[j][0] == True:
			r[j].append(i)
			r[j][0] == False
for i in range(n):
	print(r[i][1], end=' ')


(a, b) = map(int, input().split())
l = list(map(int, input().split()))
(k, c) = ([], a)
for x in l:
	if x <= c:
		for y in range(c - x + 1):
			k.append(x)
		c = x - 1
k.reverse()
print(*k)


I = lambda : int(input())
IL = lambda : list(map(int, input().split()))
(n, m) = IL()
B = IL()
st = [0] * n
for b in B:
	for j in range(b - 1, n):
		if st[j] == 0:
			st[j] = b
print(*st)


def lights(n, arr):
	ans = []
	for i in range(n[0]):
		ans.append(0)
	for i in range(len(arr)):
		for j in range(arr[i] - 1, len(ans)):
			if ans[j] == 0:
				ans[j] = arr[i]
	for i in range(len(ans)):
		print(ans[i], end=' ')
n = list(map(int, input('').split()))
arr = list(map(int, input('').split()))
lights(n, arr)


(n, m) = map(int, input().split())
b = list(map(int, input().split()))
c = [None] * n
for (i, bi) in enumerate(b):
	for j in range(bi - 1, n):
		if c[j] is not None:
			break
		c[j] = str(bi)
print(' '.join(c))


(n, m) = map(int, input().split())
l = [-1] * (n + 1)
x = list(map(int, input().split()))
for i in range(m):
	for j in range(x[i], n + 1):
		if l[j] != -1:
			break
		l[j] = str(x[i])
print(' '.join(l[1:]))


(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
b = [i for i in range(0, n + 1)]
ans = []
for i in range(len(a)):
	temp = 0
	idx = a[i]
	for j in range(a[i], len(b), 1):
		if b[j] != 0:
			b[j] = 0
			temp += 1
		else:
			break
	for j in range(temp):
		ans.append(idx)
print(*sorted(ans))


(n, m) = map(int, input().split())
dicti = {}
for x in range(n):
	dicti[x + 1] = 'on'
opers = [int(bruh) for bruh in input().split()]
for oper in opers:
	for light in range(oper, n + 1):
		if dicti[light] == 'on':
			dicti[light] = oper
lst = []
for bruhh in range(1, n + 1):
	lst.append(str(dicti[bruhh]))
print(' '.join(lst))


(n, m) = map(int, input().split())
(a, l) = (list(map(int, input().split())), [0] * n)
for b in a:
	for i in range(b - 1, len(l)):
		if l[i] is 0:
			l[i] = b
print(' '.join(map(str, l)))


(n, m) = map(int, input().split())
nums = list(map(int, input().split()))
turnedOff = [0 for i in range(n)]
for i in nums:
	for l in range(i - 1, n):
		if turnedOff[l] == 0:
			turnedOff[l] = int(i)
print(' '.join(map(str, turnedOff)))


(lamp, step) = map(int, input().split())
steps = list(map(int, input().split()))
lamps = []
for i in range(lamp):
	lamps.append(i + 1)
for i in range(lamp):
	j = 0
	while steps[j] > lamps[i]:
		j += 1
	lamps[i] = steps[j]
print(' '.join(map(str, lamps)))


(n, m) = list(map(int, input().split()))
arr = list(map(int, input().split()))
res = [0 for i in range(n + 1)]
for i in arr:
	for j in range(i, n + 1):
		if res[j] == 0:
			res[j] = i
print(*res[1:])


(n, m) = list(map(int, input().split()))
bts = list(map(int, input().split()))
done = [0 for x in range(n)]
for i in bts:
	for j in range(i - 1, n):
		if done[j] == 0:
			done[j] = i
[print(x, end=' ') for x in done]
print()


a = input().split()
m = int(a[0])
n = int(a[1])
c = input().split()
l = []
p = []
for i in range(n):
	l.append(int(c[i]))
for i in range(n):
	if m > 0:
		if l[i] <= m:
			s = m - l[i] + 1
			for j in range(s):
				p.append(l[i])
			m = l[i] - 1
p.sort()
t = ''
for i in range(len(p)):
	t = t + str(p[i]) + ' '
print(t)


(n, m) = map(int, input().split())
but = list(map(int, input().split()))
sign = [0] * (n + 1)
for i in range(m):
	x = but[i]
	for j in range(x, n + 1):
		if sign[j] == 0:
			sign[j] = x
print(sign[1], end='')
for i in range(2, n + 1):
	print('', sign[i], end='')
print()


(n, m) = map(int, input().strip().split())
b = list(map(int, input().strip().split()))
s = [0] * n
for i in b:
	for j in range(i - 1, n):
		if s[j] == 0:
			s[j] = i
print(' '.join(map(str, s)))


(n, m) = map(int, input().split())
daf = list(map(int, input().split()))
daf = daf[::-1]
has = dict()
for i in range(n):
	has[i + 1] = 0
for i in range(m):
	x = daf[i]
	for j in range(x, n + 1):
		has[j] = x
for i in has.keys():
	print(has[i], end=' ')
print()


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
d = []
for i in range(1, n + 1):
	for j in l:
		if j <= i:
			d.append(j)
			break
print(*d)


(x, y) = map(int, input().split())
p = list(map(int, input().split()))
k = [0 for i in range(1, x + 1)]
for i in p:
	for j in range(i, x + 1):
		if k[j - 1] == 0:
			k[j - 1] = i
		else:
			break
for i in k:
	print(i, end=' ')


[n, m] = list(map(int, input().split()))
lamps = [0] * n
for x in map(int, input().split()):
	i = x - 1
	while i < n and (not lamps[i]):
		lamps[i] = x
		i += 1
print(*lamps)


(n, m) = map(int, input().split())
b = map(int, input().split())
off = [''] * (n + 1)
for x in b:
	for i in range(x, n + 1):
		if not off[i]:
			off[i] = x
print(' '.join(map(str, off[1:])))


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


import time
import io
import math
import random

def timer(f):

	def tmp(*args, **kwargs):
		t = time.time()
		res = f(*args, **kwargs)
		print('Time : %f' % (time.time() - t))
		return res
	return tmp
ddd = input().split(' ')
n = int(ddd[0])
m = int(ddd[1])
ddd = input().split(' ')
array = []
for i in range(len(ddd)):
	array.append(int(ddd[i]))
res = []
for i in range(n):
	for j in range(m):
		if array[j] > i + 1:
			pass
		else:
			res.append(array[j])
			break
sss = ''
for i in range(len(res)):
	sss = sss + str(res[i]) + ' '
print(sss)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
ans = [0] * n
for i in range(m):
	b = a[i] - 1
	j = b
	while j < n and ans[j] == 0:
		ans[j] = b + 1
		j += 1
print(*ans)


X = list(map(int, input().split()))
Lights = [0 for i in range(X[0])]
Buttons = list(map(int, input().split()))
for i in Buttons:
	for j in range(i - 1, len(Lights)):
		if Lights[j] == 0:
			Lights[j] = i
print(*Lights)


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

def list_to_str(a):
	y = ''
	for i in range(len(a)):
		y = y + str(a[i])
	return y
print(list_to_str(b))


n = input().split()
n = int(n[0])
butt = {}
for i in range(1, n + 1):
	butt[i] = 0
a = input().split()
for i in a:
	for k in range(int(i), n + 1):
		if butt[k] == 0:
			butt[k] = int(i)
		else:
			continue
for i in range(1, n + 1):
	print(butt[i], end=' ')


l1 = [int(x) for x in input().split()]
l2 = [int(x) for x in input().split()]
(n, m) = (l1[0], l1[1])
c_out = []
for x in range(1, n + 1):
	i = 0
	while i < len(l2):
		if l2[i] <= x:
			c_out.append(l2[i])
			break
		i += 1
print(*c_out)


(n, m) = map(int, input().split())
v = [-1 for i in range(n)]
li = [int(i) - 1 for i in input().split()]
for i in range(m):
	for j in range(li[i], n):
		if v[j] == -1:
			v[j] = li[i] + 1
print(*v)


f = lambda : map(int, input().split())
(n, m) = f()
b = list(f())
l = list(range(n, 0, -1))
v = []
j = 0
for i in b:
	while j < n and l[j] >= i:
		v.append(i)
		j += 1
[print(i, end=' ') for i in v[::-1]]


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
z = []
for i in range(1, n + 1):
	for j in l:
		if j <= i:
			z.append(j)
			break
print(*z)


def solve(arr, n, m):
	res = [-1] * n
	for i in arr:
		for j in range(i - 1, n):
			if res[j] == -1:
				res[j] = i
	return res

def main():
	(n, m) = list(map(int, input().split(' ')))
	arr = list(map(int, input().split(' ')))
	print(*solve(arr, n, m))
main()


(n, m) = map(int, input().split())
lights = [None] * n
pushed_buttons = tuple(map(int, input().split()))
for i in pushed_buttons:
	temp = i - 1
	while temp < n and lights[temp] is None:
		lights[temp] = i
		temp += 1
print(*lights)


(n, m) = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
ans = [0] * n
for i in range(m):
	switch = b[i] - 1
	while switch < len(ans) and ans[switch] == 0:
		ans[switch] = b[i]
		switch += 1
print(' '.join((str(x) for x in ans)))


import string
(n, m) = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
l = [0] * n
for i in b:
	for j in range(i - 1, n):
		if l[j] == 0:
			l[j] = i
for i in l:
	print(i, end='')
	print(end=' ')


(n, m) = [int(i) for i in input().split()]
lights = [0] * (n + 1)
b = [int(i) for i in input().split()]
for i in b:
	for j in range(i, n + 1):
		if lights[j] == 0:
			lights[j] = i
print(' '.join([str(i) for i in lights[1:]]))


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = [0] * n
for i in range(m):
	num = a[i]
	while num <= len(b) and b[num - 1] == 0:
		b[num - 1] = a[i]
		num += 1
for i in range(len(b)):
	print(b[i], end=' ')


(n, m) = map(int, input().split())
l_p = list(map(int, input().split()))
x = [0] * (n + 1)
for b in l_p:
	for i in range(b, n + 1):
		if x[i] == 0:
			x[i] = b
		else:
			break
print(' '.join((str(x) for x in x[1:])))


l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
l3 = [0] * l1[0]
l4 = [0] * l1[0]
for i in l2:
	for j in range(i - 1, l1[0]):
		if l3[j] == 0:
			l3[j] = 1
			l4[j] = i
print(*l4, sep=' ')


(n, m) = [int(x) for x in input().split()]
a = [int(y) for y in input().split()]
i = 0
x = [0 for y in range(n)]
while i < len(a):
	j = a[i] - 1
	while j < n and x[j] == 0:
		x[j] = a[i]
		j += 1
	i += 1
for i in range(n):
	print(x[i], end=' ')


(n, m) = list(map(int, input().split()))
b_list = list(map(int, input().split()))
res = [0] * n
for b in b_list:
	for i in range(b - 1, n):
		if res[i] == 0:
			res[i] = str(b)
print(' '.join(res))


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


(n, m) = map(int, input().split())
(t, p) = ([m] * n, list(map(int, input().split())))
for (i, j) in enumerate(p):
	if t[j - 1] == m:
		t[j - 1] = i
for i in range(n - 1):
	t[i + 1] = min(t[i], t[i + 1])
for i in range(n):
	t[i] = p[t[i]]
print(' '.join(map(str, t)))


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

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

def print_arr(arr):
	print(*arr, sep=' ')
(n, m) = inp()
b = arr_inp(m)
out = [0 for i in range(n)]
for i in range(m):
	if out[b[i] - 1] == 0:
		out[b[i] - 1] = b[i]
		for j in range(b[i], n):
			if out[j] == 0:
				out[j] = b[i]
			else:
				break
print_arr(out)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
(d, c) = ({}, n + 1)
for i in range(m):
	if l[i] < c:
		for j in range(l[i], c):
			d[j] = l[i]
		c = l[i]
for i in range(n):
	print(d[i + 1], end=' ')


(n, m) = map(int, input().split())
buttons = map(int, input().split())
lamps = [0] * n
for i in buttons:
	l = i - 1
	while l < n and (not lamps[l]):
		lamps[l] = i
		l += 1
print(' '.join(list(map(str, lamps))))


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
ans = n * [0]
for i in range(m):
	for q in range(n - x[i] + 1):
		if ans[q] == 0:
			ans[q] = x[i]
ans.sort()
print(*ans)


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


def lampochki(n, lst):
	result = [0] * n
	for elem in lst:
		for i in range(elem - 1, n):
			if result[i] == 0:
				result[i] = elem
	return result
(N, M) = [int(j) for j in input().split()]
a = [int(x) for x in input().split()]
print(*lampochki(N, a))


(n, m) = map(int, input().split())
l = [int(i) for i in input().split()]
m = [i for i in range(1, n + 1)]
for i in l:
	for j in range(i - 1, n):
		m[j] = i
		n = i - 1
print(*m)


(n, m) = map(int, input().split())
arr = list(map(int, input().strip().split()))[:n]
a = [0] * n
for i in range(0, m):
	if arr[m - i - 1] <= n:
		for j in range(0, n - arr[m - i - 1] + 1):
			a[j] = arr[m - i - 1]
a.reverse()
print(*a, sep=' ')


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = []
for i in range(n):
	b.append(i + 1)
e = []
for x in a:
	while len(b) >= x:
		b.pop(len(b) - 1)
		e.append(x)
e.reverse()
for i in range(len(e)):
	print(e[i], end=' ')


(n, m) = [int(x) for x in input().split(' ')]
l = [int(x) for x in input().split(' ')]
for i in range(1, n + 1):
	for x in l:
		if x <= i:
			print(x, end=' ')
			break


(n, m) = map(int, input().split())
a = [n + 1] + list(map(int, input().split()))
b = []
for i in range(1, m + 1):
	if a[i] < min(a[:i]):
		b = b + (min(a[:i]) - a[i]) * [a[i]]
print(*sorted(b))


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = []
for i in range(1, n + 1):
	for j in range(len(a)):
		if a[j] <= i:
			b.append(a[j])
			break
print(*b)


(n, m) = map(int, input().split())
clicks = list(map(int, input().split()))
lamps = [-1] * (n + 1)
pointer = n + 1
for i in range(m):
	for j in range(clicks[i], pointer):
		lamps[j] = clicks[i]
	pointer = min(pointer, clicks[i])
lamps = lamps[1:]
print(*lamps)


_ = list(map(int, input().split()))
__ = list(map(int, input().split()))
___ = [0 for ____ in range(_[0])]
_____ = _[0]
for ____ in range(_[1]):
	for ______ in range(__[____] - 1, _____, 1):
		___[______] = __[____]
	if __[____] <= _____:
		_____ = __[____] - 1
print(*___, sep=' ')


(n, m) = [int(x) for x in input().split(' ')]
b = [int(x) for x in input().split(' ')]
ans = [0] * n
i = 0
while min(ans) == 0:
	j = b[i]
	while j <= n and ans[j - 1] == 0:
		ans[j - 1] = b[i]
		j += 1
	i += 1
print(*ans)


import sys
(n, m) = map(int, sys.stdin.readline().split())
an = list(map(int, sys.stdin.readline().split()))
ans = [0] * n
for i in an:
	for j in range(i - 1, n):
		if ans[j] == 0:
			ans[j] = i
print(' '.join(map(str, ans)))


import sys
from functools import reduce
from collections import Counter
import time
import datetime
from math import sqrt, gcd

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

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

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

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

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

def matip(n, m):
	lst = []
	for i in range(n):
		arr = lip()
		lst.insert(i, arr)
	return lst

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 minJumps(arr, n):
	jumps = [0 for i in range(n)]
	if n == 0 or arr[0] == 0:
		return float('inf')
	jumps[0] = 0
	for i in range(1, n):
		jumps[i] = float('inf')
		for j in range(i):
			if i <= j + arr[j] and jumps[j] != float('inf'):
				jumps[i] = min(jumps[i], jumps[j] + 1)
				break
	return jumps[n - 1]

def dic(arr):
	return Counter(arr)

def check_prime(n):
	if n < 2:
		return False
	for i in range(2, int(n ** 0.5) + 1, 2):
		if n % i == 0:
			return False
	return True
(n, m) = mip()
arr = lip()
lst = [0] * n
for i in range(m):
	for j in range(arr[i] - 1, n):
		if lst[j] == 0:
			lst[j] = arr[i]
print(*lst)


(n, m) = map(int, input().split())
b = list(map(int, input().split()))
l = [1] * n
a = []
for x in range(m):
	for y in range(n - 1, b[x] - 2, -1):
		if l[y] == 1:
			a.append(b[x])
			l[y] -= 1
print(' '.join(map(str, a[::-1])))


s = input().split()
(n, m) = (int(s[0]), int(s[1]))
l = ['0'] * n
for bi in input().split():
	for li in range(int(bi) - 1, n):
		if l[li] == '0':
			l[li] = bi
print(' '.join(l))


(n, m) = map(int, input().split())
blist = [int(x) for x in input().split()]
llist = [0] * n
for i in range(m):
	for j in range(blist[i] - 1, n):
		if llist[j] == 0:
			llist[j] = blist[i]
print(''.join([str(llist[i]) + ' ' for i in range(n)]))


(n, m) = map(int, input().split())
d = list(map(int, input().split()))
ans = [-1] * 101
for dd in d:
	for i in range(dd, n + 1):
		if ans[i] == -1:
			ans[i] = dd
print(*ans[1:n + 1])


(n, m) = list(map(int, input().split()))
b = list(map(int, input().split()))
x = []
c = n
for i in range(0, n):
	x.append(0)
for i in range(0, m):
	for j in range(b[i] - 1, n):
		x[j] = b[i]
		n = b[i] - 1
for i in range(0, c):
	print(x[i], end=' ')


I = lambda : map(int, input().split())
(n, _) = I()
L = [0] * n
for b in I():
	for i in range(b - 1, n):
		if L[i]:
			break
		L[i] = b
print(*L)


def checkP(string):
	if string == string[len(string) - 1:0:-1] + string[0]:
		return True
	return False

def solve():
	(n, k) = list(map(int, input().split()))
	array = [0 for i in range(n)]
	off = [int(i) for i in input().split()]
	for i in off:
		for j in range(i - 1, n):
			if array[j] == 0:
				array[j] = i
	return array
arr = solve()
for i in arr:
	print(i, end=' ')


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
s = [i + 1 for i in range(n)]
for i in range(m):
	for j in range(len(s)):
		if s[j] >= 0 and s[j] >= l[i]:
			s[j] = -l[i]
for i in s:
	print(abs(i), end=' ')


def main():
	(N, M) = map(int, input().split())
	bottoms = list(map(int, input().split()))
	lamps = [[0] * N][0]
	for i in range(M):
		for j in range(bottoms[i] - 1, N):
			if lamps[j] == 0:
				lamps[j] = bottoms[i]
	print(' '.join(map(str, lamps)))
main()


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


(n, k) = map(int, input().split())
buts = list(map(int, input().split()))
lamps = list(range(1, n + 1))
res = []
for but in buts:
	if lamps:
		res.append((but, lamps[but - 1:]))
		lamps = lamps[:but - 1]
res.sort()
for (bu, lm) in res:
	for l in lm:
		print(bu, end=' ')


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


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
trace = [0] * (n + 1)
for v in arr:
	idx = v
	while idx <= n and trace[idx] == 0:
		trace[idx] = v
		idx += 1
print(*trace[1:])


(n, m) = map(int, input().split())
arr = [int(i) for i in input().split()]
l = [int(0) for i in range(n)]
for i in arr:
	for j in range(i - 1, len(l)):
		if l[j] == 0:
			l[j] = i
print(*l)


(n, m) = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
a = [0] * n
for i in b:
	for j in range(i - 1, n):
		if a[j] == 0:
			a[j] = str(i)
print(*a)


class CodeforcesTask415ASolution:

	def __init__(self):
		self.result = ''
		self.n_m = []
		self.buttons = []

	def read_input(self):
		self.n_m = [int(x) for x in input().split(' ')]
		self.buttons = [int(x) for x in input().split(' ')]

	def process_task(self):
		off_by = [0 for x in range(self.n_m[0])]
		for button in self.buttons:
			for y in range(button - 1, self.n_m[0]):
				if not off_by[y]:
					off_by[y] = button
		self.result = ' '.join([str(x) for x in off_by])

	def get_result(self):
		return self.result
Solution = CodeforcesTask415ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


from sys import stdin
__author__ = 'artyom'

def read_next_line():
	return list(map(int, stdin.readline().strip().split()))
(n, m) = read_next_line()
indices = [-1] * n
for b in read_next_line():
	i = b - 1
	while i < n and indices[i] == -1:
		indices[i] = b
		i += 1
	if b == 1:
		break
print(' '.join(map(str, indices)))


def cal(a, i, n):
	for j in range(i - 1, n):
		if a[j] == -1:
			a[j] = i
(n, m) = map(int, input().split())
l = [*map(int, input().split())]
a = [-1] * n
for i in l:
	cal(a, i, n)
print(*a)


import sys
file = sys.stdin
__author__ = 'RaiaN'
(n, m) = file.readline().split(' ')
n = int(n)
m = int(m)
ms = [int(val) for val in file.readline().split(' ')]
dsb = [0] * n
for val in ms:
	for i in range(val - 1, n):
		if dsb[i] == 0:
			dsb[i] = val
print(' '.join((str(x) for x in dsb)))


t = input().split()
n = int(t[0])
m = int(t[1])
t = [int(x) for x in input().split()]
slon = [0 for x in range(n)]
for i in range(m):
	for j in range(t[i], n + 1):
		if j != 0 and slon[j - 1] == 0:
			slon[j - 1] = t[i]
print(*slon)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
k = []
s = []
for i in range(m):
	for j in range(l[i], n + 1):
		if j not in s:
			s.append(j)
			k.append(l[i])
for i in range(n):
	print(k[-(i + 1)], end=' ')


i = lambda : map(int, input().split())
(n, m) = i()
n += 1
a = [n] * n
for x in i():
	if x < n:
		a[x:n] = [x] * (n - x)
		n = x
print(*a[1:])


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
li = [0] * n
ans = []
for i in arr:
	for j in range(i - 1, n):
		if not li[j]:
			li[j] = 1
			ans.insert(0, i)
print(*ans)