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