#!/usr/bin/env python
#-*- coding: utf-8 -*-


class Queue:
    def __init__(self):
        self.l = []

    def enqueue(self, x):
        self.l.append(x)

    def dequeue(self):
        x = self.l[0]
        del self.l[0]
        return x

    def is_empty(self):
        return len(self.l) == 0


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


if __name__ == '__main__':
    n, q = map(int, raw_input().split())
    Q = Queue()
    i = 0
    while i != n:
        tmp = raw_input().split()
        Q.enqueue(Process(tmp[0], int(tmp[1])))
        i += 1
    cnt = 0
    while not Q.is_empty():
        p = Q.dequeue()
        if p.time > q:
            p.time -= q
            cnt += q
            Q.enqueue(p)
        else:
            cnt += p.time
            print p.name, cnt class Queue:
    def __init__(self):
        self.l = []

    def enqueue(self, x):
        self.l.append(x)

    def dequeue(self):
        x = self.l[0]
        del self.l[0]
        return x

    def is_empty(self):
        return len(self.l) == 0 Queue def __init__(self):
        self.l = []

     __init__ self.l = [] self.l self l [] self self def enqueue(self, x):
        self.l.append(x)

     enqueue self.l.append(x) self.l.append self.l self l append x self self x x def dequeue(self):
        x = self.l[0]
        del self.l[0]
        return x

     dequeue x = self.l[0] x self.l[0] self.l self l 0 del self.l[0] self.l[0] self.l self l 0 return x x self self def is_empty(self):
        return len(self.l) == 0 is_empty return len(self.l) == 0 len(self.l) == 0 len(self.l) len self.l self l 0 self self class Process:
    def __init__(self, name, time):
        self.name = name
        self.time = time Process 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 if __name__ == '__main__':
    n, q = map(int, raw_input().split())
    Q = Queue()
    i = 0
    while i != n:
        tmp = raw_input().split()
        Q.enqueue(Process(tmp[0], int(tmp[1])))
        i += 1
    cnt = 0
    while not Q.is_empty():
        p = Q.dequeue()
        if p.time > q:
            p.time -= q
            cnt += q
            Q.enqueue(p)
        else:
            cnt += p.time
            print p.name, cnt __name__ == '__main__' __name__ '__main__' n, q = map(int, raw_input().split()) n map(int, raw_input().split()) map int raw_input().split() ().split () raw_input split q Q = Queue() Q Queue() Queue i = 0 i 0 while i != n:
        tmp = raw_input().split()
        Q.enqueue(Process(tmp[0], int(tmp[1])))
        i += 1
     i != n i n tmp = raw_input().split() tmp raw_input().split() ().split () raw_input split Q.enqueue(Process(tmp[0], int(tmp[1]))) Q.enqueue Q enqueue Process(tmp[0], int(tmp[1])) Process tmp[0] tmp 0 int(tmp[1]) int tmp[1] tmp 1 i += 1 i 1 cnt = 0 cnt 0 while not Q.is_empty():
        p = Q.dequeue()
        if p.time > q:
            p.time -= q
            cnt += q
            Q.enqueue(p)
        else:
            cnt += p.time
            print p.name, cnt not Q.is_empty() Q.is_empty() Q.is_empty Q is_empty p = Q.dequeue() p Q.dequeue() Q.dequeue Q dequeue if p.time > q:
            p.time -= q
            cnt += q
            Q.enqueue(p)
        else:
            cnt += p.time
            print p.name, cnt p.time > q p.time p time q p.time -= q p.time p time q cnt += q cnt q Q.enqueue(p) Q.enqueue Q enqueue p cnt += p.time cnt p.time p time print p.name p name cnt cnt += q q cnt i += 1 1 i p = Q.dequeue() Q.dequeue() p class Process:
    def __init__(self, name, time):
        self.name = name
        self.time = time class Process:
    def __init__(self, name, time):
        self.name = name
        self.time = time Process Q = Queue() Queue() Q cnt = 0 0 cnt i = 0 0 i class Queue:
    def __init__(self):
        self.l = []

    def enqueue(self, x):
        self.l.append(x)

    def dequeue(self):
        x = self.l[0]
        del self.l[0]
        return x

    def is_empty(self):
        return len(self.l) == 0 class Queue:
    def __init__(self):
        self.l = []

    def enqueue(self, x):
        self.l.append(x)

    def dequeue(self):
        x = self.l[0]
        del self.l[0]
        return x

    def is_empty(self):
        return len(self.l) == 0 Queue q = map(int, raw_input().split()) map(int, raw_input().split()) q tmp = raw_input().split() raw_input().split() tmp n, q = map(int, raw_input().split()) map(int, raw_input().split()) n cnt += p.time p.time cnt
#!/usr/bin/env python
#-*- coding: utf-8 -*-


class Queue:
    def __init__(self):
        self.l = []

    def enqueue(self, x):
        self.l.append(x)

    def dequeue(self):
        x = self.l[0]
        del self.l[0]
        return x

    def is_empty(self):
        return len(self.l) == 0


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


if __name__ == '__main__':
    n, q = map(int, raw_input().split())
    Q = Queue()
    i = 0
    while i != n:
        tmp = raw_input().split()
        Q.enqueue(Process(tmp[0], int(tmp[1])))
        i += 1
    cnt = 0
    while not Q.is_empty():
        p = Q.dequeue()
        if p.time > q:
            p.time -= q
            cnt += q
            Q.enqueue(p)
        else:
            cnt += p.time
            print p.name, cnt
