h,n = map(int,input().split()) c = 1 for i in range(n-1): hs = int(input()) if hs > h: c += 1 if c == 1: print("1st") elif c == 2: print("2nd") elif c == 3: print("3rd") else: print(str(c)+"th")