# Arrington Harper
# Alabama School of Fine Arts
#Intermediate 3
def ACSL2():
for x in range(5):
num = input("Input: ")
first = int(num[0]);
# remove the first number
num = num[1:]
it = ""
ans = []
# get the first number
# and remove it from the rest of the number
for n in range(first):
it = it + num[0]
num = num[1:]
ans.append(it)
# sorry for my poor variable names
it2 = 0
stay = int(it)
stayLength = len(num)
for i in range(len(num)+1):
length = len(num);
it2 = int(it2)
# if the number is bigger than the previous number
# add it to ans and replace compare the next numbers to it
# if not the last iteration, get the last number of num to be compared
if (it2 > stay):
ans.append(it2)
stay = it2+0
if (i+1 <= stayLength):
it2 = num[length-1]
# else add the last digit of num to the end of the number
else:
if (i+1 <= stayLength):
it2 = str(it2) + num[length-1]
# shorten num by one number
num = num[:(length-1)]
# print the number w/o brackets and stuff
sans = [str(a) for a in ans]
print(" ".join(sans))