h,m = map(int, input().split()) x = 1 for i in range(m-1): if h < int(input()): x += 1 s = ["st","nd","rd","th"] print(x, s[min(x%10,4)-1], sep='')