height, test_case = gets.chomp.split().map(&:to_i) height_list = Array.new for i in 0...(test_case - 1) do height_list << gets.chomp.to_i end height_list << height res = height_list.sort!{|a, b| b <=> a }.index(height) + 1 print res if res == 1 puts "st" elsif res == 2 puts "nd" elsif res == 3 puts "rd" else puts "th" end