from collections import OrderedDict

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

for i in range(n):
    name, time = input().split()
    od.update({name: int(time)})
total = 0

while len(od) > 0:
    name, time = od.popitem(False)
    if time <= q:
        total += time
        print("{} {}".format(name, total))
    else:
        total += q
        time -= q
        od.update({name: time}) from collections import OrderedDict n, q = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split q od = OrderedDict() od OrderedDict() OrderedDict for i in range(n):
    name, time = input().split()
    od.update({name: int(time)}) i range(n) range n name, time = input().split() name input().split() ().split () input split time od.update({name: int(time)}) od.update od update {name: int(time)} name name int(time) int time total = 0 total 0 while len(od) > 0:
    name, time = od.popitem(False)
    if time <= q:
        total += time
        print("{} {}".format(name, total))
    else:
        total += q
        time -= q
        od.update({name: time}) len(od) > 0 len(od) len od 0 name, time = od.popitem(False) name od.popitem(False) od.popitem od popitem False time if time <= q:
        total += time
        print("{} {}".format(name, total))
    else:
        total += q
        time -= q
        od.update({name: time}) time <= q time q total += time total time print("{} {}".format(name, total)) print "{} {}".format(name, total) "{} {}".format "{} {}" format name total total += q total q time -= q time q od.update({name: time}) od.update od update {name: time} name name time od = OrderedDict() OrderedDict() od time = input().split() input().split() time n, q = map(int, input().split()) map(int, input().split()) n total = 0 0 total total += q q total time -= q q time q = map(int, input().split()) map(int, input().split()) q total += time time total name, time = od.popitem(False) od.popitem(False) name name, time = input().split() input().split() name time = od.popitem(False) od.popitem(False) time
from collections import OrderedDict

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

for i in range(n):
    name, time = input().split()
    od.update({name: int(time)})
total = 0

while len(od) > 0:
    name, time = od.popitem(False)
    if time <= q:
        total += time
        print("{} {}".format(name, total))
    else:
        total += q
        time -= q
        od.update({name: time})