#-*- coding:utf-8 -*- if __name__ == "__main__": H, N = list(map(int, input().split())) ans = 1 for i in range(N-1): if H < int(input()): ans += 1 if ans == 1: print("{}st".format(ans)) elif ans == 2: print("{}nd".format(ans)) elif ans == 3: print("{}rd".format(ans)) else: print("{}th".format(ans))