n,q = list(map(int, input().split()))
P = [[p,int(t)] for p,t in [input().split() for _ in range(n)]]
time = 0
while len(P) > 0:
    pi = P.pop(0)
    if pi[1] > q:
        P.append([pi[0],pi[1]-q])
        time += q
    else:
        time += pi[1]
        print(pi[0],time) 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,int(t)] for p,t in [input().split() for _ in range(n)] for p,t in [input().split() for _ in range(n)] p t [input().split() for _ in range(n)] for p,t in [input().split() for _ in range(n)] [p,int(t)] p int(t) int t P = [[p,int(t)] for p,t in [input().split() for _ in range(n)]] P [[p,int(t)] for p,t in [input().split() for _ in range(n)]] time = 0 time 0 while len(P) > 0:
    pi = P.pop(0)
    if pi[1] > q:
        P.append([pi[0],pi[1]-q])
        time += q
    else:
        time += pi[1]
        print(pi[0],time) len(P) > 0 len(P) len P 0 pi = P.pop(0) pi P.pop(0) P.pop P pop 0 if pi[1] > q:
        P.append([pi[0],pi[1]-q])
        time += q
    else:
        time += pi[1]
        print(pi[0],time) pi[1] > q pi[1] pi 1 q P.append([pi[0],pi[1]-q]) P.append P append [pi[0],pi[1]-q] pi[0] pi 0 pi[1]-q pi[1] pi 1 q time += q time q time += pi[1] time pi[1] pi 1 print(pi[0],time) print pi[0] pi 0 time q = list(map(int, input().split())) list(map(int, input().split())) q time = 0 0 time n,q = list(map(int, input().split())) list(map(int, input().split())) n time += pi[1] pi[1] time time += q q time pi = P.pop(0) P.pop(0) pi P = [[p,int(t)] for p,t in [input().split() for _ in range(n)]] [[p,int(t)] for p,t in [input().split() for _ in range(n)]] P
n,q = list(map(int, input().split()))
P = [[p,int(t)] for p,t in [input().split() for _ in range(n)]]
time = 0
while len(P) > 0:
    pi = P.pop(0)
    if pi[1] > q:
        P.append([pi[0],pi[1]-q])
        time += q
    else:
        time += pi[1]
        print(pi[0],time)