def hoge(a): ret = str(a) if a%10 == 1: ret += "st" elif a%10 == 2: ret += "nd" elif a%10 == 3: ret += "rd" else: ret += "th" return ret H, N = map(int, input().split()) cnt = 1 for i in range(N-1): h = int(input()) cnt += 1 if H < h else 0 print(hoge(cnt))