def parse(l):
    name, time = l.split()
    return (name, int(time))


n, q = map(int, input().split())
queue = list(parse(input()) for _ in range(n))
time = 0

while queue:
    (name, remain_time) = queue.pop(0)
    if remain_time > q:
        time += q
        queue.append((name, remain_time - q))
    else:
        time += remain_time
        print(name, time) def parse(l):
    name, time = l.split()
    return (name, int(time)) parse name, time = l.split() name l.split() l.split l split time return (name, int(time)) (name, int(time)) name int(time) int time l l n, q = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split q queue = list(parse(input()) for _ in range(n)) queue list(parse(input()) for _ in range(n)) list parse(input()) parse input() input time = 0 time 0 while queue:
    (name, remain_time) = queue.pop(0)
    if remain_time > q:
        time += q
        queue.append((name, remain_time - q))
    else:
        time += remain_time
        print(name, time) queue (name, remain_time) = queue.pop(0) (name, remain_time) name remain_time queue.pop(0) queue.pop queue pop 0 if remain_time > q:
        time += q
        queue.append((name, remain_time - q))
    else:
        time += remain_time
        print(name, time) remain_time > q remain_time q time += q time q queue.append((name, remain_time - q)) queue.append queue append (name, remain_time - q) name remain_time - q remain_time q time += remain_time time remain_time print(name, time) print name time def parse(l):
    name, time = l.split()
    return (name, int(time)) def parse(l):
    name, time = l.split()
    return (name, int(time)) parse time += q q time time = 0 0 time time += remain_time remain_time time n, q = map(int, input().split()) map(int, input().split()) n q = map(int, input().split()) map(int, input().split()) q queue = list(parse(input()) for _ in range(n)) list(parse(input()) for _ in range(n)) queue
def parse(l):
    name, time = l.split()
    return (name, int(time))


n, q = map(int, input().split())
queue = list(parse(input()) for _ in range(n))
time = 0

while queue:
    (name, remain_time) = queue.pop(0)
    if remain_time > q:
        time += q
        queue.append((name, remain_time - q))
    else:
        time += remain_time
        print(name, time)