import Data.List

mysort::[(Int,Int)]->[(Int,Int)]
mysort dat = let cmpr (x,_) (y,_) = compare x y in sortBy cmpr dat

indexed::[(Int,Int)]-> Int -> Int
indexed d i = let  (ans,_) = head (eat d (i-1)) in ans

eat::[(Int,Int)]->Int -> [(Int,Int)]
eat d j = let (x,n) = head d in if j < n then (x,n-j):(tail d) else eat (tail d) (j-n)

n_get::Int ->IO [(Int,Int)]
n_get 0 =return []
n_get n =do
  d<-getLine
  let a:b:[]= map read (words d)
  rest <- n_get (n-1)
  return ((a,b):rest)


main::IO()
main=do
  nkc<-getLine
  let n:k:[]= map read (words nkc)
  dat<-n_get n
  print (indexed (mysort dat) k)
