from collections import deque

n,q = map(int,input().split())
qu = deque([])
time = 0
for i in range(n):
    a,b = input().split()
    qu.append([a,int(b)])

while len(qu) > 0:
    c = qu.popleft()
    if c[1] <= q:
        time += c[1]
        print(c[0],time)
    else:
        time += q
        qu.append([c[0],c[1]-q]) from collections import deque n,q = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split q qu = deque([]) qu deque([]) deque [] time = 0 time 0 for i in range(n):
    a,b = input().split()
    qu.append([a,int(b)]) i range(n) range n a,b = input().split() a input().split() ().split () input split b qu.append([a,int(b)]) qu.append qu append [a,int(b)] a int(b) int b while len(qu) > 0:
    c = qu.popleft()
    if c[1] <= q:
        time += c[1]
        print(c[0],time)
    else:
        time += q
        qu.append([c[0],c[1]-q]) len(qu) > 0 len(qu) len qu 0 c = qu.popleft() c qu.popleft() qu.popleft qu popleft if c[1] <= q:
        time += c[1]
        print(c[0],time)
    else:
        time += q
        qu.append([c[0],c[1]-q]) c[1] <= q c[1] c 1 q time += c[1] time c[1] c 1 print(c[0],time) print c[0] c 0 time time += q time q qu.append([c[0],c[1]-q]) qu.append qu append [c[0],c[1]-q] c[0] c 0 c[1]-q c[1] c 1 q time += c[1] c[1] time a,b = input().split() input().split() a time += q q time n,q = map(int,input().split()) map(int,input().split()) n time = 0 0 time c = qu.popleft() qu.popleft() c qu = deque([]) deque([]) qu b = input().split() input().split() b q = map(int,input().split()) map(int,input().split()) q
from collections import deque

n,q = map(int,input().split())
qu = deque([])
time = 0
for i in range(n):
    a,b = input().split()
    qu.append([a,int(b)])

while len(qu) > 0:
    c = qu.popleft()
    if c[1] <= q:
        time += c[1]
        print(c[0],time)
    else:
        time += q
        qu.append([c[0],c[1]-q])
