from Queue import Queue

n, q = [ int( val ) for val in raw_input( ).split( " " ) ]
names = Queue( )
times = Queue( )
for i in range( n ):
	name, time = raw_input( ).split( " " )
	names.put( name )
	times.put( int( time ) )
 
qsum = 0
output = []
while not times.empty( ):
	name = names.get( )
	time = times.get( )
	if time <= q:
		qsum += time
		output.append( "{:s} {:d}".format( name, qsum ) )
	else:
		times.put( time - q )
		names.put( name )
		qsum += q

print( "\n".join( output ) ) from Queue import Queue int( val ) for val in raw_input( ).split( " " ) for val in raw_input( ).split( " " ) val raw_input( ).split( " " ) ( ).split ( ) raw_input split " " for val in raw_input( ).split( " " ) int( val ) int val n, q = [ int( val ) for val in raw_input( ).split( " " ) ] n [ int( val ) for val in raw_input( ).split( " " ) ] q names = Queue( ) names Queue( ) Queue times = Queue( ) times Queue( ) Queue for i in range( n ):
	name, time = raw_input( ).split( " " )
	names.put( name )
	times.put( int( time ) )
  i range( n ) range n name, time = raw_input( ).split( " " ) name raw_input( ).split( " " ) ( ).split ( ) raw_input split " " time names.put( name ) names.put names put name times.put( int( time ) ) times.put times put int( time ) int time qsum = 0 qsum 0 output = [] output [] while not times.empty( ):
	name = names.get( )
	time = times.get( )
	if time <= q:
		qsum += time
		output.append( "{:s} {:d}".format( name, qsum ) )
	else:
		times.put( time - q )
		names.put( name )
		qsum += q not times.empty( ) times.empty( ) times.empty times empty name = names.get( ) name names.get( ) names.get names get time = times.get( ) time times.get( ) times.get times get if time <= q:
		qsum += time
		output.append( "{:s} {:d}".format( name, qsum ) )
	else:
		times.put( time - q )
		names.put( name )
		qsum += q time <= q time q qsum += time qsum time output.append( "{:s} {:d}".format( name, qsum ) ) output.append output append "{:s} {:d}".format( name, qsum ) "{:s} {:d}".format "{:s} {:d}" format name qsum times.put( time - q ) times.put times put time - q time q names.put( name ) names.put names put name qsum += q qsum q print( "\n".join( output ) ) print "\n".join( output ) "\n".join "\n" join output qsum += time time qsum name, time = raw_input( ).split( " " ) raw_input( ).split( " " ) name n, q = [ int( val ) for val in raw_input( ).split( " " ) ] [ int( val ) for val in raw_input( ).split( " " ) ] n names = Queue( ) Queue( ) names qsum = 0 0 qsum qsum += q q qsum q = [ int( val ) for val in raw_input( ).split( " " ) ] [ int( val ) for val in raw_input( ).split( " " ) ] q time = raw_input( ).split( " " ) raw_input( ).split( " " ) time output = [] [] output times = Queue( ) Queue( ) times time = times.get( ) times.get( ) time name = names.get( ) names.get( ) name
from Queue import Queue

n, q = [ int( val ) for val in raw_input( ).split( " " ) ]
names = Queue( )
times = Queue( )
for i in range( n ):
	name, time = raw_input( ).split( " " )
	names.put( name )
	times.put( int( time ) )
 
qsum = 0
output = []
while not times.empty( ):
	name = names.get( )
	time = times.get( )
	if time <= q:
		qsum += time
		output.append( "{:s} {:d}".format( name, qsum ) )
	else:
		times.put( time - q )
		names.put( name )
		qsum += q

print( "\n".join( output ) )