first =input(); firstdata = first.split(" "); sintyo = int(firstdata[0]); num = int(firstdata[1])-1; result=1; for inputer in range(num): hikaku = int(input()); if hikaku > sintyo: result = result+1; if result==1: result = str(result)+"st"; elif result ==2: result = str(result)+"nd"; elif result ==3: result = str(result)+"rd"; else: result = str(result)+"th"; print(result);