# 写一个冒泡搞定
def maopao(lenth, list1, flag):
for i in range(lenth):
for j in range(lenth-i-1):
if flag == '0':
if list1[j] > list1[j+1]:
list1[j], list1[j+1] = list1[j+1], list1[j]
else:
if list1[j] < list1[j+1]:
list1[j], list1[j+1] = list1[j+1], list1[j]
return [str(x) for x in list1]
res = []
while True:
try:
a = int(input())
b = [int(x) for x in input().split()] # 列表
c = input()
result = maopao(a, b, c)
res.append(result)
except EOFError:
for x in res:
print(' '.join(x))
break 
京公网安备 11010502036488号