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: # ----------------for input------------------------
  numberAndQuontum = input().split()
  number = int(numberAndQuontum[0])
  Quontum = int(numberAndQuontum[1])
  allProcessList = []
  
  index = 0
  while index < number:
      nameAndTime = input().split()
      nameTimeList = []
      nameTimeList.append(nameAndTime[0])
      nameTimeList.append(int(nameAndTime[1]))
      allProcessList.append(nameTimeList)
      index += 1
  # ----------------for input------------------------
  
  
  def schedule(Quontum, allProcessList):
      time = 0
      listForReturn = []
      while True:
          index = 0
          if allProcessList == []:
              break
          length = len(allProcessList)
          while index < length:
              if allProcessList[index][1] <= Quontum:
                  time += allProcessList[index][1]
                  listForReturn.append(allProcessList[index][0] + " " + str(time))
                  allProcessList[index] = []
                  index += 1
              else:
                  time += Quontum
                  listForAppend = [
                      allProcessList[index][0],
                      allProcessList[index][1] - Quontum,
                  ]
                  allProcessList.append(listForAppend)
                  allProcessList[index] = []
                  index += 1
          while [] in allProcessList:
              allProcessList.remove([])
      for printPair in listForReturn:
          print(printPair)
  
  
  # -------------------for main---------------------------
  schedule(Quontum, allProcessList)
  
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"}]