from collections import deque

if __name__ == "__main__":
    n, q = input().split()
    n, q = int(n), int(q)
    s = 0
    a = deque([list(map(str,input().split())) for _ in range(n)])

    while len(a):
        x = a.popleft()
        if int(x[1]) - q <= 0:
            s += int(x[1])
            print(x[0], s)
        else:
            x[1] = str(int(x[1]) - q)
            s += q
            a.append(x) from collections import deque if __name__ == "__main__":
    n, q = input().split()
    n, q = int(n), int(q)
    s = 0
    a = deque([list(map(str,input().split())) for _ in range(n)])

    while len(a):
        x = a.popleft()
        if int(x[1]) - q <= 0:
            s += int(x[1])
            print(x[0], s)
        else:
            x[1] = str(int(x[1]) - q)
            s += q
            a.append(x) __name__ == "__main__" __name__ "__main__" n, q = input().split() n input().split() ().split () input split q n, q = int(n), int(q) n int(n) int n q int(q) int q s = 0 s 0 list(map(str,input().split())) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) list(map(str,input().split())) list map(str,input().split()) map str input().split() ().split () input split a = deque([list(map(str,input().split())) for _ in range(n)]) a deque([list(map(str,input().split())) for _ in range(n)]) deque [list(map(str,input().split())) for _ in range(n)] while len(a):
        x = a.popleft()
        if int(x[1]) - q <= 0:
            s += int(x[1])
            print(x[0], s)
        else:
            x[1] = str(int(x[1]) - q)
            s += q
            a.append(x) len(a) len a x = a.popleft() x a.popleft() a.popleft a popleft if int(x[1]) - q <= 0:
            s += int(x[1])
            print(x[0], s)
        else:
            x[1] = str(int(x[1]) - q)
            s += q
            a.append(x) int(x[1]) - q <= 0 int(x[1]) - q int(x[1]) int x[1] x 1 q 0 s += int(x[1]) s int(x[1]) int x[1] x 1 print(x[0], s) print x[0] x 0 s x[1] = str(int(x[1]) - q) x[1] x 1 str(int(x[1]) - q) str int(x[1]) - q int(x[1]) int x[1] x 1 q s += q s q a.append(x) a.append a append x q = input().split() input().split() q s = 0 0 s s += int(x[1]) int(x[1]) s s += q q s n, q = int(n), int(q) int(n) n a = deque([list(map(str,input().split())) for _ in range(n)]) deque([list(map(str,input().split())) for _ in range(n)]) a n, q = input().split() input().split() n q = int(n), int(q) int(q) q x = a.popleft() a.popleft() x
from collections import deque

if __name__ == "__main__":
    n, q = input().split()
    n, q = int(n), int(q)
    s = 0
    a = deque([list(map(str,input().split())) for _ in range(n)])

    while len(a):
        x = a.popleft()
        if int(x[1]) - q <= 0:
            s += int(x[1])
            print(x[0], s)
        else:
            x[1] = str(int(x[1]) - q)
            s += q
            a.append(x)
