from collections import deque

def solve(n,t):

  q=deque([])

  for i in range(n):

    l=list(input().split())

    q.append(l)

  time=0

  while not len(q)==0:

    x=q.popleft()

    if int(x[1])-t>0:

      x[1]=str(int(x[1])-t)

      time+=t

      q.append(x)

    else:

      print((x[0]+" "+str(time+int(x[1]))))

      time+=int(x[1])

n,t=list(map(int,input().split()))

solve(n,t)

import collections

q=collections.deque()

n,m=list(map(int,input().split()))

for i in range(n):

  a,b=input().split()

  b=int(b)

  q.append([a,b])

t=0

while len(q)!=0:

  n=q.popleft()

  if n[1]<=m:

    t+=n[1]

    print((n[0],str(t)))

  else:

    t+=m

    n[1]-=m

    q.append(n)

from collections import deque


def solve(n, t):
    q = deque([])
    for i in range(n):
        l = list(input().split())
        q.append(l)
    time = 0
    while not len(q) == 0:
        x = q.popleft()
        if int(x[1]) - t > 0:
            x[1] = str(int(x[1]) - t)
            time += t
            q.append(x)
        else:
            print((x[0] + " " + str(time + int(x[1]))))
            time += int(x[1])


n, t = list(map(int, input().split()))
solve(n, t)

import collections

q = collections.deque()
n, m = list(map(int, input().split()))
for i in range(n):
    a, b = input().split()
    b = int(b)
    q.append([a, b])
t = 0
while len(q) != 0:
    n = q.popleft()
    if n[1] <= m:
        t += n[1]
        print((n[0], str(t)))
    else:
        t += m
        n[1] -= m
        q.append(n)

-from collections import deque +import collections - -def solve(n, t): -    q = deque([]) -    for i in range(n): -        l = list(input().split()) -        q.append(l) -    time = 0 -    while not len(q) == 0: -        x = q.popleft() -        if int(x[1]) - t > 0: -            x[1] = str(int(x[1]) - t) -            time += t -            q.append(x) -        else: -            print((x[0] + " " + str(time + int(x[1])))) -            time += int(x[1]) - - -n, t = list(map(int, input().split())) -solve(n, t) +q = collections.deque() +n, m = list(map(int, input().split())) +for i in range(n): +    a, b = input().split() +    b = int(b) +    q.append([a, b]) +t = 0 +while len(q) != 0: +    n = q.popleft() +    if n[1] <= m: +        t += n[1] +        print((n[0], str(t))) +    else: +        t += m +        n[1] -= m +        q.append(n)