n,q = map(int,input().split())

tmp =  [input().split() for i in range(n)]
a = [[name,int(time)] for name,time in tmp]

total_time = 0

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

tmp =  [input().split() for i in range(n)]
a = [[name,int(time)] for name,time in tmp]

total_time = 0

count = 0
while(a):
    current = a.pop(0)
    if(current[1] > q):
        current[1] -= q
        a.append(current)
        total_time += q
    else:
        total_time += current[1]
        print(current[0],total_time,sep = " ")
