import sys input = sys.stdin.readline H,N=map(int,input().split()) ANS=1 for i in range(N-1): h=int(input()) if h>H: ANS+=1 if ANS%10==1: print(ANS,end="") print("st") elif ANS%10==2: print(ANS,end="") print("nd") elif ANS%10==3: print(ANS,end="") print("rd") else: print(ANS,end="") print("th")