{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE BangPatterns #-} import Control.Applicative import Control.Monad import Control.Arrow import Data.List import Data.Maybe import Data.Char import qualified Data.ByteString.Char8 as B import Text.Printf readInt = ( readLn :: IO Int ) readInts = map ( read :: String -> Int ) . words <$> getLine getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine which a b f = if f then a else b mp [ a, b ] = ( a, b ) main = do [ h, n ] <- readInts hs <- replicateM ( n - 1 ) readInt putStrLn $ conv $ fst $ fromJust $ find ( ( == h ) . snd ) $ zip [ 1 .. ] $ reverse $ sort $ h : hs conv x | x `mod` 10 == 1 = show x ++ "st" | x `mod` 10 == 2 = show x ++ "nd" | x `mod` 10 == 3 = show x ++ "rd" | otherwise = show x ++ "th"