H, N = map(int, input().split()) Hi = [int(input()) for _ in range(N-1)] rank = 1 for x in Hi: if x > H: rank += 1 if rank % 10 == 1: print(str(rank) + "st") elif rank % 10 == 2: print(str(rank) + "nd") elif rank % 10 == 3: print(str(rank) + "rd") else: print(str(rank) + "th")