import Control.Monad
import Data.List
import Data.Ord
import Data.Maybe
import qualified Data.ByteString.Char8 as B

main = do
 [_,k] <- map read . words <$> getLine
 ab <- map (map (fst . fromJust . B.readInt) . B.words) . B.lines <$> B.getContents
 print (bigArray k (sortBy (comparing head) ab))

bigArray k ([a,b]:ab)
 | k <= b = a
 | otherwise = bigArray (k-b) ab