import Data.List

createAry :: Int -> Int -> IO Int 
createAry a b = createAry' a b []
  where
    createAry' :: Int -> Int -> [Int] -> IO Int 
    createAry' a b list
      | a == 0 = return (list !! b)
      | otherwise = do
          [c, d] <- map read . words <$> getLine
          createAry' (a - 1) b $ list ++ take d (repeat c)


main = do
  [a, b] <- map read . words <$> getLine
  createAry a b >>= print