import java.io.*;
import 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;
   }
  
  
}
public class Main {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);
       int inputProcesses = in.nextInt();
       int quantum = in.nextInt();

       Queue<Process> processes = new LinkedList<Process>();

       for (int i = 0; i < inputProcesses; i++) {
           String nameIndex = in.next();
           int timeIndex = in.nextInt();
          
           Process processIndex = new Process(nameIndex, timeIndex);
           processes.add(processIndex);
       }
       int currTime = 0;
       while(!processes.isEmpty()) {
           Process head = processes.poll();
           if (head.getTime() > quantum) {
          	   head.setTime(head.getTime() - quantum);
               currTime += quantum;
               processes.add(head);
           }
           else {
               currTime += head.getTime();
               System.out.println(head.getName() + " " + currTime);
           }
       }
   }
} import java.io.*; io.* java import java.util.*; util.* java 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 in = new Scanner(System.in);
       int inputProcesses = in.nextInt();
       int quantum = in.nextInt();

       Queue<Process> processes = new LinkedList<Process>();

       for (int i = 0; i < inputProcesses; i++) {
           String nameIndex = in.next();
           int timeIndex = in.nextInt();
          
           Process processIndex = new Process(nameIndex, timeIndex);
           processes.add(processIndex);
       }
       int currTime = 0;
       while(!processes.isEmpty()) {
           Process head = processes.poll();
           if (head.getTime() > quantum) {
          	   head.setTime(head.getTime() - quantum);
               currTime += quantum;
               processes.add(head);
           }
           else {
               currTime += head.getTime();
               System.out.println(head.getName() + " " + currTime);
           }
       }
   }
} Main public static void main(String[] args) {

       Scanner in = new Scanner(System.in);
       int inputProcesses = in.nextInt();
       int quantum = in.nextInt();

       Queue<Process> processes = new LinkedList<Process>();

       for (int i = 0; i < inputProcesses; i++) {
           String nameIndex = in.next();
           int timeIndex = in.nextInt();
          
           Process processIndex = new Process(nameIndex, timeIndex);
           processes.add(processIndex);
       }
       int currTime = 0;
       while(!processes.isEmpty()) {
           Process head = processes.poll();
           if (head.getTime() > quantum) {
          	   head.setTime(head.getTime() - quantum);
               currTime += quantum;
               processes.add(head);
           }
           else {
               currTime += head.getTime();
               System.out.println(head.getName() + " " + currTime);
           }
       }
   } main {

       Scanner in = new Scanner(System.in);
       int inputProcesses = in.nextInt();
       int quantum = in.nextInt();

       Queue<Process> processes = new LinkedList<Process>();

       for (int i = 0; i < inputProcesses; i++) {
           String nameIndex = in.next();
           int timeIndex = in.nextInt();
          
           Process processIndex = new Process(nameIndex, timeIndex);
           processes.add(processIndex);
       }
       int currTime = 0;
       while(!processes.isEmpty()) {
           Process head = processes.poll();
           if (head.getTime() > quantum) {
          	   head.setTime(head.getTime() - quantum);
               currTime += quantum;
               processes.add(head);
           }
           else {
               currTime += head.getTime();
               System.out.println(head.getName() + " " + currTime);
           }
       }
   } Scanner in = new Scanner(System.in); in new Scanner(System.in) int inputProcesses = in.nextInt(); inputProcesses in.nextInt() in.nextInt in int quantum = in.nextInt(); quantum in.nextInt() in.nextInt in Queue<Process> processes = new LinkedList<Process>(); processes new LinkedList<Process>() for (int i = 0; i < inputProcesses; i++) {
           String nameIndex = in.next();
           int timeIndex = in.nextInt();
          
           Process processIndex = new Process(nameIndex, timeIndex);
           processes.add(processIndex);
       } int i = 0; int i = 0; i 0 i < inputProcesses i inputProcesses i++ i++ i {
           String nameIndex = in.next();
           int timeIndex = in.nextInt();
          
           Process processIndex = new Process(nameIndex, timeIndex);
           processes.add(processIndex);
       } {
           String nameIndex = in.next();
           int timeIndex = in.nextInt();
          
           Process processIndex = new Process(nameIndex, timeIndex);
           processes.add(processIndex);
       } String nameIndex = in.next(); nameIndex in.next() in.next in int timeIndex = in.nextInt(); timeIndex in.nextInt() in.nextInt in Process processIndex = new Process(nameIndex, timeIndex); processIndex new Process(nameIndex, timeIndex) processes.add(processIndex) processes.add processes processIndex int currTime = 0; currTime 0 while(!processes.isEmpty()) {
           Process head = processes.poll();
           if (head.getTime() > quantum) {
          	   head.setTime(head.getTime() - quantum);
               currTime += quantum;
               processes.add(head);
           }
           else {
               currTime += head.getTime();
               System.out.println(head.getName() + " " + currTime);
           }
       } !processes.isEmpty() processes.isEmpty() processes.isEmpty processes {
           Process head = processes.poll();
           if (head.getTime() > quantum) {
          	   head.setTime(head.getTime() - quantum);
               currTime += quantum;
               processes.add(head);
           }
           else {
               currTime += head.getTime();
               System.out.println(head.getName() + " " + currTime);
           }
       } Process head = processes.poll(); head processes.poll() processes.poll processes if (head.getTime() > quantum) {
          	   head.setTime(head.getTime() - quantum);
               currTime += quantum;
               processes.add(head);
           }
           else {
               currTime += head.getTime();
               System.out.println(head.getName() + " " + currTime);
           } head.getTime() > quantum head.getTime() head.getTime head quantum {
          	   head.setTime(head.getTime() - quantum);
               currTime += quantum;
               processes.add(head);
           } head.setTime(head.getTime() - quantum) head.setTime head head.getTime() - quantum head.getTime() head.getTime head quantum currTime += quantum currTime quantum processes.add(head) processes.add processes head {
               currTime += head.getTime();
               System.out.println(head.getName() + " " + currTime);
           } currTime += head.getTime() currTime head.getTime() head.getTime head System.out.println(head.getName() + " " + currTime) System.out.println System.out System System.out head.getName() + " " + currTime head.getName() + " " + currTime head.getName() head.getName head " " currTime String[] args args public class Main {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);
       int inputProcesses = in.nextInt();
       int quantum = in.nextInt();

       Queue<Process> processes = new LinkedList<Process>();

       for (int i = 0; i < inputProcesses; i++) {
           String nameIndex = in.next();
           int timeIndex = in.nextInt();
          
           Process processIndex = new Process(nameIndex, timeIndex);
           processes.add(processIndex);
       }
       int currTime = 0;
       while(!processes.isEmpty()) {
           Process head = processes.poll();
           if (head.getTime() > quantum) {
          	   head.setTime(head.getTime() - quantum);
               currTime += quantum;
               processes.add(head);
           }
           else {
               currTime += head.getTime();
               System.out.println(head.getName() + " " + currTime);
           }
       }
   }
} public class Main {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);
       int inputProcesses = in.nextInt();
       int quantum = in.nextInt();

       Queue<Process> processes = new LinkedList<Process>();

       for (int i = 0; i < inputProcesses; i++) {
           String nameIndex = in.next();
           int timeIndex = in.nextInt();
          
           Process processIndex = new Process(nameIndex, timeIndex);
           processes.add(processIndex);
       }
       int currTime = 0;
       while(!processes.isEmpty()) {
           Process head = processes.poll();
           if (head.getTime() > quantum) {
          	   head.setTime(head.getTime() - quantum);
               currTime += quantum;
               processes.add(head);
           }
           else {
               currTime += head.getTime();
               System.out.println(head.getName() + " " + currTime);
           }
       }
   }
} Main
import java.io.*;
import 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;
   }
  
  
}
public class Main {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);
       int inputProcesses = in.nextInt();
       int quantum = in.nextInt();

       Queue<Process> processes = new LinkedList<Process>();

       for (int i = 0; i < inputProcesses; i++) {
           String nameIndex = in.next();
           int timeIndex = in.nextInt();
          
           Process processIndex = new Process(nameIndex, timeIndex);
           processes.add(processIndex);
       }
       int currTime = 0;
       while(!processes.isEmpty()) {
           Process head = processes.poll();
           if (head.getTime() > quantum) {
          	   head.setTime(head.getTime() - quantum);
               currTime += quantum;
               processes.add(head);
           }
           else {
               currTime += head.getTime();
               System.out.println(head.getName() + " " + currTime);
           }
       }
   }
}
