class Proc:
    def __init__(self, name, time):
        self.name = name
        self.time = time

n, q = map(int, input().split(' '))
procs = []

for i in range(0, n):
    name, time = input().split(' ')
    time = int(time)
    procs.append(Proc(name, time))

elapsed = 0
while len(procs) > 0:
    proc = procs.pop(0)
    if proc.time > q:
        proc.time -= q
        elapsed += q
        procs.append(proc)
    else:
        elapsed += proc.time
        print(proc.name, elapsed) class Proc:
    def __init__(self, name, time):
        self.name = name
        self.time = time Proc def __init__(self, name, time):
        self.name = name
        self.time = time __init__ self.name = name self.name self name name self.time = time self.time self time time self self name name time time n, q = map(int, input().split(' ')) n map(int, input().split(' ')) map int input().split(' ') ().split () input split ' ' q procs = [] procs [] for i in range(0, n):
    name, time = input().split(' ')
    time = int(time)
    procs.append(Proc(name, time)) i range(0, n) range 0 n name, time = input().split(' ') name input().split(' ') ().split () input split ' ' time time = int(time) time int(time) int time procs.append(Proc(name, time)) procs.append procs append Proc(name, time) Proc name time elapsed = 0 elapsed 0 while len(procs) > 0:
    proc = procs.pop(0)
    if proc.time > q:
        proc.time -= q
        elapsed += q
        procs.append(proc)
    else:
        elapsed += proc.time
        print(proc.name, elapsed) len(procs) > 0 len(procs) len procs 0 proc = procs.pop(0) proc procs.pop(0) procs.pop procs pop 0 if proc.time > q:
        proc.time -= q
        elapsed += q
        procs.append(proc)
    else:
        elapsed += proc.time
        print(proc.name, elapsed) proc.time > q proc.time proc time q proc.time -= q proc.time proc time q elapsed += q elapsed q procs.append(proc) procs.append procs append proc elapsed += proc.time elapsed proc.time proc time print(proc.name, elapsed) print proc.name proc name elapsed elapsed = 0 0 elapsed procs = [] [] procs time = int(time) int(time) time n, q = map(int, input().split(' ')) map(int, input().split(' ')) n elapsed += proc.time proc.time elapsed proc = procs.pop(0) procs.pop(0) proc elapsed += q q elapsed name, time = input().split(' ') input().split(' ') name time = input().split(' ') input().split(' ') time class Proc:
    def __init__(self, name, time):
        self.name = name
        self.time = time class Proc:
    def __init__(self, name, time):
        self.name = name
        self.time = time Proc q = map(int, input().split(' ')) map(int, input().split(' ')) q
class Proc:
    def __init__(self, name, time):
        self.name = name
        self.time = time

n, q = map(int, input().split(' '))
procs = []

for i in range(0, n):
    name, time = input().split(' ')
    time = int(time)
    procs.append(Proc(name, time))

elapsed = 0
while len(procs) > 0:
    proc = procs.pop(0)
    if proc.time > q:
        proc.time -= q
        elapsed += q
        procs.append(proc)
    else:
        elapsed += proc.time
        print(proc.name, elapsed)