H,N = map(int,input().split(' ')) Hn = [int(input()) for i in range(N-1)] Hn.append(H) Hn.sort(reverse=True) for i in range(N): if Hn[i] != H: pass else: if i%10 == 0: print('{0}st'.format(i+1)) elif i%10 == 1: print('{0}nd'.format(i+1)) elif i%10 == 2: print('{0}rd'.format(i+1)) elif i >= 3: print('{0}th'.format(i+1))