n,q = map(int,input().split())
name = []
time = []
for i in range(n):
    a = input().split()
    name.append(a[0])
    time.append(int(a[1]))
s = 0
while name:
    if time[0]> q:
        time[0] -= q
        time.append(time.pop(0))
        name.append(name.pop(0))
        s += q
    else:
        s += time[0] 
        time.pop(0)
        print(name.pop(0),s) n,q = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split q name = [] name [] time = [] time [] for i in range(n):
    a = input().split()
    name.append(a[0])
    time.append(int(a[1])) i range(n) range n a = input().split() a input().split() ().split () input split name.append(a[0]) name.append name append a[0] a 0 time.append(int(a[1])) time.append time append int(a[1]) int a[1] a 1 s = 0 s 0 while name:
    if time[0]> q:
        time[0] -= q
        time.append(time.pop(0))
        name.append(name.pop(0))
        s += q
    else:
        s += time[0] 
        time.pop(0)
        print(name.pop(0),s) name if time[0]> q:
        time[0] -= q
        time.append(time.pop(0))
        name.append(name.pop(0))
        s += q
    else:
        s += time[0] 
        time.pop(0)
        print(name.pop(0),s) time[0]> q time[0] time 0 q time[0] -= q time[0] time 0 q time.append(time.pop(0)) time.append time append time.pop(0) time.pop time pop 0 name.append(name.pop(0)) name.append name append name.pop(0) name.pop name pop 0 s += q s q s += time[0] s time[0] time 0 time.pop(0) time.pop time pop 0 print(name.pop(0),s) print name.pop(0) name.pop name pop 0 s q = map(int,input().split()) map(int,input().split()) q name = [] [] name a = input().split() input().split() a s += time[0] time[0] s s = 0 0 s s += q q s n,q = map(int,input().split()) map(int,input().split()) n time = [] [] time
n,q = map(int,input().split())
name = []
time = []
for i in range(n):
    a = input().split()
    name.append(a[0])
    time.append(int(a[1]))
s = 0
while name:
    if time[0]> q:
        time[0] -= q
        time.append(time.pop(0))
        name.append(name.pop(0))
        s += q
    else:
        s += time[0] 
        time.pop(0)
        print(name.pop(0),s)