n, time=map(int,raw_input().split())
p = []
t = []
for _ in xrange(n):
    a = raw_input().split()
    p.append(a[0])
    t.append(int(a[1]))
alltime = 0
while True:
    if len(p)==0:
        break
    if t[0]<=time:
        alltime+=t[0]
        print p.pop(0),
        t.pop(0)
        print alltime
    else:
        t.append(t[0])
        t.pop(0)
        t[-1]-=time
        alltime += time
        p.append(p[0])
        p.pop(0) n, time=map(int,raw_input().split()) n map(int,raw_input().split()) map int raw_input().split() ().split () raw_input split time p = [] p [] t = [] t [] for _ in xrange(n):
    a = raw_input().split()
    p.append(a[0])
    t.append(int(a[1])) _ xrange(n) xrange n a = raw_input().split() a raw_input().split() ().split () raw_input split p.append(a[0]) p.append p append a[0] a 0 t.append(int(a[1])) t.append t append int(a[1]) int a[1] a 1 alltime = 0 alltime 0 while True:
    if len(p)==0:
        break
    if t[0]<=time:
        alltime+=t[0]
        print p.pop(0),
        t.pop(0)
        print alltime
    else:
        t.append(t[0])
        t.pop(0)
        t[-1]-=time
        alltime += time
        p.append(p[0])
        p.pop(0) True if len(p)==0:
        break
     len(p)==0 len(p) len p 0 break if t[0]<=time:
        alltime+=t[0]
        print p.pop(0),
        t.pop(0)
        print alltime
    else:
        t.append(t[0])
        t.pop(0)
        t[-1]-=time
        alltime += time
        p.append(p[0])
        p.pop(0) t[0]<=time t[0] t 0 time alltime+=t[0] alltime t[0] t 0 print p.pop(0) p.pop p pop 0 t.pop(0) t.pop t pop 0 print t.append(t[0]) t.append t append t[0] t 0 t.pop(0) t.pop t pop 0 t[-1]-=time t[-1] t -1 time alltime += time alltime time p.append(p[0]) p.append p append p[0] p 0 p.pop(0) p.pop p pop 0 n, time=map(int,raw_input().split()) map(int,raw_input().split()) n alltime+=t[0] t[0] alltime t = [] [] t alltime = 0 0 alltime time=map(int,raw_input().split()) map(int,raw_input().split()) time alltime += time time alltime p = [] [] p a = raw_input().split() raw_input().split() a
n, time=map(int,raw_input().split())
p = []
t = []
for _ in xrange(n):
    a = raw_input().split()
    p.append(a[0])
    t.append(int(a[1]))
alltime = 0
while True:
    if len(p)==0:
        break
    if t[0]<=time:
        alltime+=t[0]
        print p.pop(0),
        t.pop(0)
        print alltime
    else:
        t.append(t[0])
        t.pop(0)
        t[-1]-=time
        alltime += time
        p.append(p[0])
        p.pop(0)