import Data.List                                                                                                                                                            

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


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