n ,q = map(int, input().split())
ntlist = []
for i in range(n):
    nt = list(map(str, input().split()))
    ntlist.append(nt)
tp = 0
while (len(ntlist)):
    nt = ntlist.pop(0)
    if (int(nt[1])> q):
        nt[1] = int(nt[1]) - q
        tp += q
        ntlist.append(nt)
    else:
        tp += int(nt[1])
        nt[1] = 0
        print(nt[0], tp)
 n ,q = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split q ntlist = [] ntlist [] for i in range(n):
    nt = list(map(str, input().split()))
    ntlist.append(nt) i range(n) range n nt = list(map(str, input().split())) nt list(map(str, input().split())) list map(str, input().split()) map str input().split() ().split () input split ntlist.append(nt) ntlist.append ntlist append nt tp = 0 tp 0 while (len(ntlist)):
    nt = ntlist.pop(0)
    if (int(nt[1])> q):
        nt[1] = int(nt[1]) - q
        tp += q
        ntlist.append(nt)
    else:
        tp += int(nt[1])
        nt[1] = 0
        print(nt[0], tp) len(ntlist) len ntlist nt = ntlist.pop(0) nt ntlist.pop(0) ntlist.pop ntlist pop 0 if (int(nt[1])> q):
        nt[1] = int(nt[1]) - q
        tp += q
        ntlist.append(nt)
    else:
        tp += int(nt[1])
        nt[1] = 0
        print(nt[0], tp) int(nt[1])> q int(nt[1]) int nt[1] nt 1 q nt[1] = int(nt[1]) - q nt[1] nt 1 int(nt[1]) - q int(nt[1]) int nt[1] nt 1 q tp += q tp q ntlist.append(nt) ntlist.append ntlist append nt tp += int(nt[1]) tp int(nt[1]) int nt[1] nt 1 nt[1] = 0 nt[1] nt 1 0 print(nt[0], tp) print nt[0] nt 0 tp q = map(int, input().split()) map(int, input().split()) q tp = 0 0 tp ntlist = [] [] ntlist nt = list(map(str, input().split())) list(map(str, input().split())) nt nt = ntlist.pop(0) ntlist.pop(0) nt n ,q = map(int, input().split()) map(int, input().split()) n tp += q q tp tp += int(nt[1]) int(nt[1]) tp
n ,q = map(int, input().split())
ntlist = []
for i in range(n):
    nt = list(map(str, input().split()))
    ntlist.append(nt)
tp = 0
while (len(ntlist)):
    nt = ntlist.pop(0)
    if (int(nt[1])> q):
        nt[1] = int(nt[1]) - q
        tp += q
        ntlist.append(nt)
    else:
        tp += int(nt[1])
        nt[1] = 0
        print(nt[0], tp)

