H,N = list(map(int,input().split())) rank = 1 for _ in range(N-1): if int(input()) > H:rank += 1 if rank % 10 == 1: S = 'st' elif rank % 10 == 2: S = 'nd' elif rank % 10 == 3: S = 'rd' else: S = 'th' print(str(rank)+S)