output_description: For each process, prints its name and the time the process finished in order.
input_description: _n_ _q_  
  _name 1 time1_  
  _name 2 time2_  
  ...  
  _name n timen_  
  
  In the first line the number of processes _n_ and the quantum _q_ are given
  separated by a single space.
  
  In the following _n_ lines, names and times for the _n_ processes are given.
  _name i_ and _time i_ are separated by a single space.
attempt: # encoding: utf-8
  
  import sys
  from collections import deque
  
  
  class Solution:
      @staticmethod
      def message_queue():
          # write your code here
          # tasks = deque(map(lambda x: x.split(), sys.stdin.readlines()))
          task_num, task_time = map(int, input().split())
          _input = sys.stdin.readlines()
  
          task_deque = deque(
              map(lambda x: dict(name=x.split()[0], time=int(x.split()[-1])), _input)
          )
          total_time = 0
  
          while task_deque:
              item = task_deque.popleft()
              if item["time"] <= task_time:
                  total_time += item["time"]
                  print(item["name"], total_time)
              else:
                  item["time"] -= task_time
                  total_time += task_time
                  task_deque.append(item)
  
  
  if __name__ == "__main__":
      solution = Solution()
      solution.message_queue()
  
problem_description: Input
  
  _n_ _q_  
  _name 1 time1_  
  _name 2 time2_  
  ...  
  _name n timen_  
  
  In the first line the number of processes _n_ and the quantum _q_ are given
  separated by a single space.
  
  In the following _n_ lines, names and times for the _n_ processes are given.
  _name i_ and _time i_ are separated by a single space.
samples: [{"input": "5 100\n    p1 150\n    p2 80\n    p3 200\n    p4 350\n    p5 20", "output": "p2 180\n    p5 400\n    p1 450\n    p3 550\n    p4 800"}]