n, q = (int(x) for x in input().split())
process = [input().split() for _ in range(n)]
time = 0
while process:
    p = process.pop(0)
    if int(p[1]) <= q:
        time += int(p[1])
        print(p[0], time)
    else:
        time += q
        process.append([p[0], int(p[1]) - q]) int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x n, q = (int(x) for x in input().split()) n (int(x) for x in input().split()) q input().split() for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) input().split() ().split () input split process = [input().split() for _ in range(n)] process [input().split() for _ in range(n)] time = 0 time 0 while process:
    p = process.pop(0)
    if int(p[1]) <= q:
        time += int(p[1])
        print(p[0], time)
    else:
        time += q
        process.append([p[0], int(p[1]) - q]) process p = process.pop(0) p process.pop(0) process.pop process pop 0 if int(p[1]) <= q:
        time += int(p[1])
        print(p[0], time)
    else:
        time += q
        process.append([p[0], int(p[1]) - q]) int(p[1]) <= q int(p[1]) int p[1] p 1 q time += int(p[1]) time int(p[1]) int p[1] p 1 print(p[0], time) print p[0] p 0 time time += q time q process.append([p[0], int(p[1]) - q]) process.append process append [p[0], int(p[1]) - q] p[0] p 0 int(p[1]) - q int(p[1]) int p[1] p 1 q time = 0 0 time p = process.pop(0) process.pop(0) p time += q q time q = (int(x) for x in input().split()) (int(x) for x in input().split()) q process = [input().split() for _ in range(n)] [input().split() for _ in range(n)] process n, q = (int(x) for x in input().split()) (int(x) for x in input().split()) n time += int(p[1]) int(p[1]) time
n, q = (int(x) for x in input().split())
process = [input().split() for _ in range(n)]
time = 0
while process:
    p = process.pop(0)
    if int(p[1]) <= q:
        time += int(p[1])
        print(p[0], time)
    else:
        time += q
        process.append([p[0], int(p[1]) - q])