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

elapsed = 0
while len(tasks):
    name, time = tasks.pop(0)
    if time > q:
        elapsed += q
        tasks.append((name, time - q))
    else:
        elapsed += time
        print('{0} {1}'.format(name, elapsed)) 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 tasks = [(li[0], int(li[1])) for li in [input().split() for _ in range(n)]] tasks [(li[0], int(li[1])) for li in [input().split() for _ in range(n)]] elapsed = 0 elapsed 0 while len(tasks):
    name, time = tasks.pop(0)
    if time > q:
        elapsed += q
        tasks.append((name, time - q))
    else:
        elapsed += time
        print('{0} {1}'.format(name, elapsed)) len(tasks) len tasks name, time = tasks.pop(0) name tasks.pop(0) tasks.pop tasks pop 0 time if time > q:
        elapsed += q
        tasks.append((name, time - q))
    else:
        elapsed += time
        print('{0} {1}'.format(name, elapsed)) time > q time q elapsed += q elapsed q tasks.append((name, time - q)) tasks.append tasks append (name, time - q) name time - q time q elapsed += time elapsed time print('{0} {1}'.format(name, elapsed)) print '{0} {1}'.format(name, elapsed) '{0} {1}'.format '{0} {1}' format name elapsed n, q = map(int, input().split()) map(int, input().split()) n name, time = tasks.pop(0) tasks.pop(0) name elapsed += q q elapsed q = map(int, input().split()) map(int, input().split()) q time = tasks.pop(0) tasks.pop(0) time elapsed += time time elapsed tasks = [(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)]] tasks elapsed = 0 0 elapsed
n, q = map(int, input().split())
tasks = [(li[0], int(li[1])) for li in [input().split() for _ in range(n)]]

elapsed = 0
while len(tasks):
    name, time = tasks.pop(0)
    if time > q:
        elapsed += q
        tasks.append((name, time - q))
    else:
        elapsed += time
        print('{0} {1}'.format(name, elapsed))