import Data.List main = do [h,n] <- map read . words <$> getLine :: IO [Int] hs <- map read . words <$> getContents putStrLn $ format $ height h n hs height h n hs = fst $ head $ filter ((==h).snd) $ zip [1..] $ reverse $ sort (h:hs) format n | last s == '1' = s ++ "st" | last s == '2' = s ++ "nd" | last s == '3' = s ++ "rd" | otherwise = s ++ "th" where s = show n