h, n = map(int, input().split()) data = [h] for i in range(n-1): data.append(int(input())) data.sort(reverse=True) m = data.index(h) + 1 i = m%10 if i == 1: print("%dst" % i) elif i == 2: print("%dnd" % i) elif i == 3: print("%drd" % i) else: print("%dth" % i)