n, q = [ int( val ) for val in raw_input( ).split( " " ) ]
ps = [0]*n
t = [0]*n
for i in range( n ):
	ps[i], t[i] = raw_input( ).split( " " )


output = []
qsum = 0
while t:
	psi = ps.pop( 0 )
	ti = int( t.pop( 0 ) )
	if ti <= q:
		qsum += ti	
		output.append( psi+" "+str( qsum ) )
	else:
		t.append( ti - q )
		ps.append( psi )
		qsum += q

print( "\n".join( output ) ) 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 ps = [0]*n ps [0]*n [0] 0 n t = [0]*n t [0]*n [0] 0 n for i in range( n ):
	ps[i], t[i] = raw_input( ).split( " " ) i range( n ) range n ps[i], t[i] = raw_input( ).split( " " ) ps[i] ps i raw_input( ).split( " " ) ( ).split ( ) raw_input split " " t[i] t i output = [] output [] qsum = 0 qsum 0 while t:
	psi = ps.pop( 0 )
	ti = int( t.pop( 0 ) )
	if ti <= q:
		qsum += ti	
		output.append( psi+" "+str( qsum ) )
	else:
		t.append( ti - q )
		ps.append( psi )
		qsum += q t psi = ps.pop( 0 ) psi ps.pop( 0 ) ps.pop ps pop 0 ti = int( t.pop( 0 ) ) ti int( t.pop( 0 ) ) int t.pop( 0 ) t.pop t pop 0 if ti <= q:
		qsum += ti	
		output.append( psi+" "+str( qsum ) )
	else:
		t.append( ti - q )
		ps.append( psi )
		qsum += q ti <= q ti q qsum += ti qsum ti output.append( psi+" "+str( qsum ) ) output.append output append psi+" "+str( qsum ) psi+" " psi " " str( qsum ) str qsum t.append( ti - q ) t.append t append ti - q ti q ps.append( psi ) ps.append ps append psi qsum += q qsum q print( "\n".join( output ) ) print "\n".join( output ) "\n".join "\n" join output output = [] [] output psi = ps.pop( 0 ) ps.pop( 0 ) psi q = [ int( val ) for val in raw_input( ).split( " " ) ] [ int( val ) for val in raw_input( ).split( " " ) ] q n, q = [ int( val ) for val in raw_input( ).split( " " ) ] [ int( val ) for val in raw_input( ).split( " " ) ] n ti = int( t.pop( 0 ) ) int( t.pop( 0 ) ) ti qsum += ti ti qsum qsum += q q qsum ps = [0]*n [0]*n ps qsum = 0 0 qsum t = [0]*n [0]*n t
n, q = [ int( val ) for val in raw_input( ).split( " " ) ]
ps = [0]*n
t = [0]*n
for i in range( n ):
	ps[i], t[i] = raw_input( ).split( " " )


output = []
qsum = 0
while t:
	psi = ps.pop( 0 )
	ti = int( t.pop( 0 ) )
	if ti <= q:
		qsum += ti	
		output.append( psi+" "+str( qsum ) )
	else:
		t.append( ti - q )
		ps.append( psi )
		qsum += q

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