H,N = list(map(int,input().split())) h = list(map(int,input().split())) rank = 1 for i in h: if i > 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(rank,S,sep = '')