nama, N = map(int, input().split()) rank = 1 for i in range(N-1): cm = int(input()) if nama < cm: rank += 1 if rank.endswith(1): print(rank +"st") elif rank.endswith(2): print(rank +"nd") elif rank.endswith(3): print(rank +"rd") else: print(rank +"th")