import Data.Functor((<$>))
import Text.Printf(printf)

main :: IO ()
main = do 
        q  <- (read :: String -> Int).last.words <$> getLine
        xs <- reverse.map ((\[n, t] -> (n, (read :: String -> Int) t)).words).lines <$> getContents
        solve xs q 0

solve                     :: [(String, Int)] -> Int -> Int -> IO ()
solve []            _ _   = return ()
solve xs q cnt = let (n, t) = last xs 
                     t'     = t - q
                     cnt'   = cnt + q
                     m      = cnt' + t'
                 in if t' > 0 then solve ((n, t') : init xs) q cnt'
                              else printf"%s %d\n" n m >> solve (init xs) q m