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

processes = [[li[0], int(li[1])] for li in [input().split() for _ in range(n)]]


elapsed_time = 0
while len(processes):
    process = processes.pop(0)
    if process[1] > q:
        process[1] -= q
        processes.append(process)
        elapsed_time += q
    else:
        elapsed_time += process[1]
        print(process[0], elapsed_time) n, q = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split q [li[0], int(li[1])] for li in [input().split() for _ in range(n)] for li in [input().split() for _ in range(n)] li [input().split() for _ in range(n)] for li in [input().split() for _ in range(n)] [li[0], int(li[1])] li[0] li 0 int(li[1]) int li[1] li 1 processes = [[li[0], int(li[1])] for li in [input().split() for _ in range(n)]] processes [[li[0], int(li[1])] for li in [input().split() for _ in range(n)]] elapsed_time = 0 elapsed_time 0 while len(processes):
    process = processes.pop(0)
    if process[1] > q:
        process[1] -= q
        processes.append(process)
        elapsed_time += q
    else:
        elapsed_time += process[1]
        print(process[0], elapsed_time) len(processes) len processes process = processes.pop(0) process processes.pop(0) processes.pop processes pop 0 if process[1] > q:
        process[1] -= q
        processes.append(process)
        elapsed_time += q
    else:
        elapsed_time += process[1]
        print(process[0], elapsed_time) process[1] > q process[1] process 1 q process[1] -= q process[1] process 1 q processes.append(process) processes.append processes append process elapsed_time += q elapsed_time q elapsed_time += process[1] elapsed_time process[1] process 1 print(process[0], elapsed_time) print process[0] process 0 elapsed_time elapsed_time = 0 0 elapsed_time processes = [[li[0], int(li[1])] for li in [input().split() for _ in range(n)]] [[li[0], int(li[1])] for li in [input().split() for _ in range(n)]] processes elapsed_time += q q elapsed_time n, q = map(int, input().split()) map(int, input().split()) n process = processes.pop(0) processes.pop(0) process q = map(int, input().split()) map(int, input().split()) q elapsed_time += process[1] process[1] elapsed_time
n, q = map(int, input().split())

processes = [[li[0], int(li[1])] for li in [input().split() for _ in range(n)]]


elapsed_time = 0
while len(processes):
    process = processes.pop(0)
    if process[1] > q:
        process[1] -= q
        processes.append(process)
        elapsed_time += q
    else:
        elapsed_time += process[1]
        print(process[0], elapsed_time)