n,q = list(map(int, input().split()))
p = [0]*n
t = [0]*n

for i in range(n):
    p[i],t[i] = list(input().split())

i = 0
sum_t = 0
while 1:
    if i==len(t):
        break
    tmp_t = int(t[i])-q
    if tmp_t<=0:
        sum_t += int(t[i])
        print(p[i],sum_t)
    else:
        sum_t += q
        p.append(p[i])
        t.append(tmp_t)        
    i+=1 n,q = list(map(int, input().split())) n list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split q p = [0]*n p [0]*n [0] 0 n t = [0]*n t [0]*n [0] 0 n for i in range(n):
    p[i],t[i] = list(input().split()) i range(n) range n p[i],t[i] = list(input().split()) p[i] p i list(input().split()) list input().split() ().split () input split t[i] t i i = 0 i 0 sum_t = 0 sum_t 0 while 1:
    if i==len(t):
        break
    tmp_t = int(t[i])-q
    if tmp_t<=0:
        sum_t += int(t[i])
        print(p[i],sum_t)
    else:
        sum_t += q
        p.append(p[i])
        t.append(tmp_t)        
    i+=1 1 if i==len(t):
        break
     i==len(t) i len(t) len t break tmp_t = int(t[i])-q tmp_t int(t[i])-q int(t[i]) int t[i] t i q if tmp_t<=0:
        sum_t += int(t[i])
        print(p[i],sum_t)
    else:
        sum_t += q
        p.append(p[i])
        t.append(tmp_t)        
     tmp_t<=0 tmp_t 0 sum_t += int(t[i]) sum_t int(t[i]) int t[i] t i print(p[i],sum_t) print p[i] p i sum_t sum_t += q sum_t q p.append(p[i]) p.append p append p[i] p i t.append(tmp_t) t.append t append tmp_t i+=1 i 1 q = list(map(int, input().split())) list(map(int, input().split())) q sum_t += q q sum_t tmp_t = int(t[i])-q int(t[i])-q tmp_t n,q = list(map(int, input().split())) list(map(int, input().split())) n sum_t = 0 0 sum_t p = [0]*n [0]*n p sum_t += int(t[i]) int(t[i]) sum_t t = [0]*n [0]*n t i = 0 0 i i+=1 1 i
n,q = list(map(int, input().split()))
p = [0]*n
t = [0]*n

for i in range(n):
    p[i],t[i] = list(input().split())

i = 0
sum_t = 0
while 1:
    if i==len(t):
        break
    tmp_t = int(t[i])-q
    if tmp_t<=0:
        sum_t += int(t[i])
        print(p[i],sum_t)
    else:
        sum_t += q
        p.append(p[i])
        t.append(tmp_t)        
    i+=1
