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( " " )

qsum = 0
while t:
    psi = ps.pop( 0 )
    ti = int( t.pop( 0 ) )
    if ti <= q:
        qsum += ti
        print( "{:s} {:d}".format( psi, qsum ) )        
    else:
        t.append( ti - q )
        ps.append( psi )
        qsum += q 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 qsum = 0 qsum 0 while t:
    psi = ps.pop( 0 )
    ti = int( t.pop( 0 ) )
    if ti <= q:
        qsum += ti
        print( "{:s} {:d}".format( psi, 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
        print( "{:s} {:d}".format( psi, qsum ) )        
    else:
        t.append( ti - q )
        ps.append( psi )
        qsum += q ti <= q ti q qsum += ti qsum ti print( "{:s} {:d}".format( psi, qsum ) ) print "{:s} {:d}".format( psi, qsum ) "{:s} {:d}".format "{:s} {:d}" format psi 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 n, q = [ int( val ) for val in raw_input( ).split( " " ) ] [ int( val ) for val in raw_input( ).split( " " ) ] n ps = [0]*n [0]*n ps qsum += ti ti qsum ti = int( t.pop( 0 ) ) int( t.pop( 0 ) ) ti q = [ int( val ) for val in raw_input( ).split( " " ) ] [ int( val ) for val in raw_input( ).split( " " ) ] q qsum = 0 0 qsum qsum += q q qsum psi = ps.pop( 0 ) ps.pop( 0 ) psi 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( " " )

qsum = 0
while t:
    psi = ps.pop( 0 )
    ti = int( t.pop( 0 ) )
    if ti <= q:
        qsum += ti
        print( "{:s} {:d}".format( psi, qsum ) )        
    else:
        t.append( ti - q )
        ps.append( psi )
        qsum += q