H,N = map(int,input().split()) tall = [] tall.append([-H,"nama"]) for x in range(N - 1): h = int(input()) tall.append([-h,""]) tall.sort() now = 1 for h,men in tall: if men == "nama": break now += 1 S = str(now) if S[-1] == "1": print(S + "st") elif S[-1] == "2": print(S + "nd") elif S[-1] == "3": print(S + "rd") else: print(S + "th")