import java.io.IOException;
import java.io.InputStream;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

class Process {
   private String name;
   private int time;
  
   public Process(String name, int time) {
       this.name = name;
       this.time = time;
   }
  
   public int getTime() {
       return time;
   }

   public void setTime(int time) {
       this.time = time;
   }

   public String getName() {
       return name;
   }
  
  
}
public class Main {

   public static void main(String[] args) {
      
       // scanner for input.
       Scanner s = new Scanner(System.in);
       // accept number of processes.
       int numberOfProcesses = s.nextInt();
       // accept time quantum.
       int timeQuantum = s.nextInt();
      
       // declare queue for processes.
       Queue<Process> processes = new LinkedList<Process>();
      
       // fill the queue form the input.
       for (int i = 0; i<numberOfProcesses; i++) {
           String namei = s.next();
           int timei = s.nextInt();
          
           Process processi = new Process(namei, timei);
           processes.add(processi);
       }
      
       // intialize current ongoing time.
       int currTime = 0;
       // check if process(Queue) is empty
       while(!processes.isEmpty()) {
           // get the head of queue and remove from queue.
           Process p = processes.poll();
           // if the current process is greater than time quantum
           // subtract its remaining time. and add the current time.
           // add the process back to queue.
           if (p.getTime() > timeQuantum) {
               p.setTime(p.getTime() - timeQuantum);
               currTime += timeQuantum;
               processes.add(p);
           }
           // Else add the current time and display the output.
           else {
               currTime += p.getTime();
               System.out.println(p.getName() + " " + currTime);
           }
       }
   }
} import java.io.IOException; IOException java.io import java.io.InputStream; InputStream java.io import java.util.LinkedList; LinkedList java.util import java.util.Queue; Queue java.util import java.util.Scanner; Scanner java.util class Process {
   private String name;
   private int time;
  
   public Process(String name, int time) {
       this.name = name;
       this.time = time;
   }
  
   public int getTime() {
       return time;
   }

   public void setTime(int time) {
       this.time = time;
   }

   public String getName() {
       return name;
   }
  
  
} Process private String name; name private int time; time public Process(String name, int time) {
       this.name = name;
       this.time = time;
   } Process {
       this.name = name;
       this.time = time;
   } this.name = name this.name this this.name name this.time = time this.time this this.time time String name name int time time public int getTime() {
       return time;
   } getTime {
       return time;
   } return time; time public void setTime(int time) {
       this.time = time;
   } setTime {
       this.time = time;
   } this.time = time this.time this this.time time int time time public String getName() {
       return name;
   } getName {
       return name;
   } return name; name public class Main {

   public static void main(String[] args) {
      
       // scanner for input.
       Scanner s = new Scanner(System.in);
       // accept number of processes.
       int numberOfProcesses = s.nextInt();
       // accept time quantum.
       int timeQuantum = s.nextInt();
      
       // declare queue for processes.
       Queue<Process> processes = new LinkedList<Process>();
      
       // fill the queue form the input.
       for (int i = 0; i<numberOfProcesses; i++) {
           String namei = s.next();
           int timei = s.nextInt();
          
           Process processi = new Process(namei, timei);
           processes.add(processi);
       }
      
       // intialize current ongoing time.
       int currTime = 0;
       // check if process(Queue) is empty
       while(!processes.isEmpty()) {
           // get the head of queue and remove from queue.
           Process p = processes.poll();
           // if the current process is greater than time quantum
           // subtract its remaining time. and add the current time.
           // add the process back to queue.
           if (p.getTime() > timeQuantum) {
               p.setTime(p.getTime() - timeQuantum);
               currTime += timeQuantum;
               processes.add(p);
           }
           // Else add the current time and display the output.
           else {
               currTime += p.getTime();
               System.out.println(p.getName() + " " + currTime);
           }
       }
   }
} Main public static void main(String[] args) {
      
       // scanner for input.
       Scanner s = new Scanner(System.in);
       // accept number of processes.
       int numberOfProcesses = s.nextInt();
       // accept time quantum.
       int timeQuantum = s.nextInt();
      
       // declare queue for processes.
       Queue<Process> processes = new LinkedList<Process>();
      
       // fill the queue form the input.
       for (int i = 0; i<numberOfProcesses; i++) {
           String namei = s.next();
           int timei = s.nextInt();
          
           Process processi = new Process(namei, timei);
           processes.add(processi);
       }
      
       // intialize current ongoing time.
       int currTime = 0;
       // check if process(Queue) is empty
       while(!processes.isEmpty()) {
           // get the head of queue and remove from queue.
           Process p = processes.poll();
           // if the current process is greater than time quantum
           // subtract its remaining time. and add the current time.
           // add the process back to queue.
           if (p.getTime() > timeQuantum) {
               p.setTime(p.getTime() - timeQuantum);
               currTime += timeQuantum;
               processes.add(p);
           }
           // Else add the current time and display the output.
           else {
               currTime += p.getTime();
               System.out.println(p.getName() + " " + currTime);
           }
       }
   } main {
      
       // scanner for input.
       Scanner s = new Scanner(System.in);
       // accept number of processes.
       int numberOfProcesses = s.nextInt();
       // accept time quantum.
       int timeQuantum = s.nextInt();
      
       // declare queue for processes.
       Queue<Process> processes = new LinkedList<Process>();
      
       // fill the queue form the input.
       for (int i = 0; i<numberOfProcesses; i++) {
           String namei = s.next();
           int timei = s.nextInt();
          
           Process processi = new Process(namei, timei);
           processes.add(processi);
       }
      
       // intialize current ongoing time.
       int currTime = 0;
       // check if process(Queue) is empty
       while(!processes.isEmpty()) {
           // get the head of queue and remove from queue.
           Process p = processes.poll();
           // if the current process is greater than time quantum
           // subtract its remaining time. and add the current time.
           // add the process back to queue.
           if (p.getTime() > timeQuantum) {
               p.setTime(p.getTime() - timeQuantum);
               currTime += timeQuantum;
               processes.add(p);
           }
           // Else add the current time and display the output.
           else {
               currTime += p.getTime();
               System.out.println(p.getName() + " " + currTime);
           }
       }
   } Scanner s = new Scanner(System.in); s new Scanner(System.in) int numberOfProcesses = s.nextInt(); numberOfProcesses s.nextInt() s.nextInt s int timeQuantum = s.nextInt(); timeQuantum s.nextInt() s.nextInt s Queue<Process> processes = new LinkedList<Process>(); processes new LinkedList<Process>() for (int i = 0; i<numberOfProcesses; i++) {
           String namei = s.next();
           int timei = s.nextInt();
          
           Process processi = new Process(namei, timei);
           processes.add(processi);
       } int i = 0; int i = 0; i 0 i<numberOfProcesses i numberOfProcesses i++ i++ i {
           String namei = s.next();
           int timei = s.nextInt();
          
           Process processi = new Process(namei, timei);
           processes.add(processi);
       } {
           String namei = s.next();
           int timei = s.nextInt();
          
           Process processi = new Process(namei, timei);
           processes.add(processi);
       } String namei = s.next(); namei s.next() s.next s int timei = s.nextInt(); timei s.nextInt() s.nextInt s Process processi = new Process(namei, timei); processi new Process(namei, timei) processes.add(processi) processes.add processes processi int currTime = 0; currTime 0 while(!processes.isEmpty()) {
           // get the head of queue and remove from queue.
           Process p = processes.poll();
           // if the current process is greater than time quantum
           // subtract its remaining time. and add the current time.
           // add the process back to queue.
           if (p.getTime() > timeQuantum) {
               p.setTime(p.getTime() - timeQuantum);
               currTime += timeQuantum;
               processes.add(p);
           }
           // Else add the current time and display the output.
           else {
               currTime += p.getTime();
               System.out.println(p.getName() + " " + currTime);
           }
       } !processes.isEmpty() processes.isEmpty() processes.isEmpty processes {
           // get the head of queue and remove from queue.
           Process p = processes.poll();
           // if the current process is greater than time quantum
           // subtract its remaining time. and add the current time.
           // add the process back to queue.
           if (p.getTime() > timeQuantum) {
               p.setTime(p.getTime() - timeQuantum);
               currTime += timeQuantum;
               processes.add(p);
           }
           // Else add the current time and display the output.
           else {
               currTime += p.getTime();
               System.out.println(p.getName() + " " + currTime);
           }
       } Process p = processes.poll(); p processes.poll() processes.poll processes if (p.getTime() > timeQuantum) {
               p.setTime(p.getTime() - timeQuantum);
               currTime += timeQuantum;
               processes.add(p);
           }
           // Else add the current time and display the output.
           else {
               currTime += p.getTime();
               System.out.println(p.getName() + " " + currTime);
           } p.getTime() > timeQuantum p.getTime() p.getTime p timeQuantum {
               p.setTime(p.getTime() - timeQuantum);
               currTime += timeQuantum;
               processes.add(p);
           } p.setTime(p.getTime() - timeQuantum) p.setTime p p.getTime() - timeQuantum p.getTime() p.getTime p timeQuantum currTime += timeQuantum currTime timeQuantum processes.add(p) processes.add processes p {
               currTime += p.getTime();
               System.out.println(p.getName() + " " + currTime);
           } currTime += p.getTime() currTime p.getTime() p.getTime p System.out.println(p.getName() + " " + currTime) System.out.println System.out System System.out p.getName() + " " + currTime p.getName() + " " + currTime p.getName() p.getName p " " currTime String[] args args public class Main {

   public static void main(String[] args) {
      
       // scanner for input.
       Scanner s = new Scanner(System.in);
       // accept number of processes.
       int numberOfProcesses = s.nextInt();
       // accept time quantum.
       int timeQuantum = s.nextInt();
      
       // declare queue for processes.
       Queue<Process> processes = new LinkedList<Process>();
      
       // fill the queue form the input.
       for (int i = 0; i<numberOfProcesses; i++) {
           String namei = s.next();
           int timei = s.nextInt();
          
           Process processi = new Process(namei, timei);
           processes.add(processi);
       }
      
       // intialize current ongoing time.
       int currTime = 0;
       // check if process(Queue) is empty
       while(!processes.isEmpty()) {
           // get the head of queue and remove from queue.
           Process p = processes.poll();
           // if the current process is greater than time quantum
           // subtract its remaining time. and add the current time.
           // add the process back to queue.
           if (p.getTime() > timeQuantum) {
               p.setTime(p.getTime() - timeQuantum);
               currTime += timeQuantum;
               processes.add(p);
           }
           // Else add the current time and display the output.
           else {
               currTime += p.getTime();
               System.out.println(p.getName() + " " + currTime);
           }
       }
   }
} public class Main {

   public static void main(String[] args) {
      
       // scanner for input.
       Scanner s = new Scanner(System.in);
       // accept number of processes.
       int numberOfProcesses = s.nextInt();
       // accept time quantum.
       int timeQuantum = s.nextInt();
      
       // declare queue for processes.
       Queue<Process> processes = new LinkedList<Process>();
      
       // fill the queue form the input.
       for (int i = 0; i<numberOfProcesses; i++) {
           String namei = s.next();
           int timei = s.nextInt();
          
           Process processi = new Process(namei, timei);
           processes.add(processi);
       }
      
       // intialize current ongoing time.
       int currTime = 0;
       // check if process(Queue) is empty
       while(!processes.isEmpty()) {
           // get the head of queue and remove from queue.
           Process p = processes.poll();
           // if the current process is greater than time quantum
           // subtract its remaining time. and add the current time.
           // add the process back to queue.
           if (p.getTime() > timeQuantum) {
               p.setTime(p.getTime() - timeQuantum);
               currTime += timeQuantum;
               processes.add(p);
           }
           // Else add the current time and display the output.
           else {
               currTime += p.getTime();
               System.out.println(p.getName() + " " + currTime);
           }
       }
   }
} Main
import java.io.IOException;
import java.io.InputStream;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

class Process {
   private String name;
   private int time;
  
   public Process(String name, int time) {
       this.name = name;
       this.time = time;
   }
  
   public int getTime() {
       return time;
   }

   public void setTime(int time) {
       this.time = time;
   }

   public String getName() {
       return name;
   }
  
  
}
public class Main {

   public static void main(String[] args) {
      
       // scanner for input.
       Scanner s = new Scanner(System.in);
       // accept number of processes.
       int numberOfProcesses = s.nextInt();
       // accept time quantum.
       int timeQuantum = s.nextInt();
      
       // declare queue for processes.
       Queue<Process> processes = new LinkedList<Process>();
      
       // fill the queue form the input.
       for (int i = 0; i<numberOfProcesses; i++) {
           String namei = s.next();
           int timei = s.nextInt();
          
           Process processi = new Process(namei, timei);
           processes.add(processi);
       }
      
       // intialize current ongoing time.
       int currTime = 0;
       // check if process(Queue) is empty
       while(!processes.isEmpty()) {
           // get the head of queue and remove from queue.
           Process p = processes.poll();
           // if the current process is greater than time quantum
           // subtract its remaining time. and add the current time.
           // add the process back to queue.
           if (p.getTime() > timeQuantum) {
               p.setTime(p.getTime() - timeQuantum);
               currTime += timeQuantum;
               processes.add(p);
           }
           // Else add the current time and display the output.
           else {
               currTime += p.getTime();
               System.out.println(p.getName() + " " + currTime);
           }
       }
   }
}
