h,n=map(int,input().split()) c=1 for _ in range(n-1): if int(input())>h:c+=1 if c>3:print(str(c)+'th') else:print(('1st','2nd','3rd')[c-1])