import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String[] info = sc.nextLine().split(" ");
		Queue<Process> entries = new LinkedList<>();
		int size = Integer.parseInt(info[0]);
		int runtime = Integer.parseInt(info[1]);
		for(int i = 0; i < size; i++) {
			info = sc.nextLine().split(" ");
			entries.add(new Process(info[0], Integer.parseInt(info[1])));
		}
		sc.close();
		int totalTime = 0;
		while(entries.size() > 0) {
			Process temp = entries.remove();
			if(temp.getTime() > runtime) {
				totalTime += runtime;
				temp.setTime(temp.getTime() - runtime);
				entries.add(temp);
			}
			else {
				totalTime += temp.getTime();
				System.out.println(temp.getName() + " " + totalTime);
			}
		}
	}
}

class Process{
	String name;
	int time;
	
	public Process(String n, int t) {
		this.name = n;
		this.time = t;
	}
	
	public int getTime() {
		return this.time; 
	}
	
	public void setTime(int t) {
		this.time = t;
	}
	
	public String getName() {
		return this.name;
	}
}
 import java.util.*; util.* java public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String[] info = sc.nextLine().split(" ");
		Queue<Process> entries = new LinkedList<>();
		int size = Integer.parseInt(info[0]);
		int runtime = Integer.parseInt(info[1]);
		for(int i = 0; i < size; i++) {
			info = sc.nextLine().split(" ");
			entries.add(new Process(info[0], Integer.parseInt(info[1])));
		}
		sc.close();
		int totalTime = 0;
		while(entries.size() > 0) {
			Process temp = entries.remove();
			if(temp.getTime() > runtime) {
				totalTime += runtime;
				temp.setTime(temp.getTime() - runtime);
				entries.add(temp);
			}
			else {
				totalTime += temp.getTime();
				System.out.println(temp.getName() + " " + totalTime);
			}
		}
	}
} Main public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String[] info = sc.nextLine().split(" ");
		Queue<Process> entries = new LinkedList<>();
		int size = Integer.parseInt(info[0]);
		int runtime = Integer.parseInt(info[1]);
		for(int i = 0; i < size; i++) {
			info = sc.nextLine().split(" ");
			entries.add(new Process(info[0], Integer.parseInt(info[1])));
		}
		sc.close();
		int totalTime = 0;
		while(entries.size() > 0) {
			Process temp = entries.remove();
			if(temp.getTime() > runtime) {
				totalTime += runtime;
				temp.setTime(temp.getTime() - runtime);
				entries.add(temp);
			}
			else {
				totalTime += temp.getTime();
				System.out.println(temp.getName() + " " + totalTime);
			}
		}
	} main {
		Scanner sc = new Scanner(System.in);
		String[] info = sc.nextLine().split(" ");
		Queue<Process> entries = new LinkedList<>();
		int size = Integer.parseInt(info[0]);
		int runtime = Integer.parseInt(info[1]);
		for(int i = 0; i < size; i++) {
			info = sc.nextLine().split(" ");
			entries.add(new Process(info[0], Integer.parseInt(info[1])));
		}
		sc.close();
		int totalTime = 0;
		while(entries.size() > 0) {
			Process temp = entries.remove();
			if(temp.getTime() > runtime) {
				totalTime += runtime;
				temp.setTime(temp.getTime() - runtime);
				entries.add(temp);
			}
			else {
				totalTime += temp.getTime();
				System.out.println(temp.getName() + " " + totalTime);
			}
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String[] info = sc.nextLine().split(" "); info sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " Queue<Process> entries = new LinkedList<>(); entries new LinkedList<>() int size = Integer.parseInt(info[0]); size Integer.parseInt(info[0]) Integer.parseInt Integer info[0] info 0 int runtime = Integer.parseInt(info[1]); runtime Integer.parseInt(info[1]) Integer.parseInt Integer info[1] info 1 for(int i = 0; i < size; i++) {
			info = sc.nextLine().split(" ");
			entries.add(new Process(info[0], Integer.parseInt(info[1])));
		} int i = 0; int i = 0; i 0 i < size i size i++ i++ i {
			info = sc.nextLine().split(" ");
			entries.add(new Process(info[0], Integer.parseInt(info[1])));
		} {
			info = sc.nextLine().split(" ");
			entries.add(new Process(info[0], Integer.parseInt(info[1])));
		} info = sc.nextLine().split(" ") info sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " entries.add(new Process(info[0], Integer.parseInt(info[1]))) entries.add entries new Process(info[0], Integer.parseInt(info[1])) sc.close() sc.close sc int totalTime = 0; totalTime 0 while(entries.size() > 0) {
			Process temp = entries.remove();
			if(temp.getTime() > runtime) {
				totalTime += runtime;
				temp.setTime(temp.getTime() - runtime);
				entries.add(temp);
			}
			else {
				totalTime += temp.getTime();
				System.out.println(temp.getName() + " " + totalTime);
			}
		} entries.size() > 0 entries.size() entries.size entries 0 {
			Process temp = entries.remove();
			if(temp.getTime() > runtime) {
				totalTime += runtime;
				temp.setTime(temp.getTime() - runtime);
				entries.add(temp);
			}
			else {
				totalTime += temp.getTime();
				System.out.println(temp.getName() + " " + totalTime);
			}
		} Process temp = entries.remove(); temp entries.remove() entries.remove entries if(temp.getTime() > runtime) {
				totalTime += runtime;
				temp.setTime(temp.getTime() - runtime);
				entries.add(temp);
			}
			else {
				totalTime += temp.getTime();
				System.out.println(temp.getName() + " " + totalTime);
			} temp.getTime() > runtime temp.getTime() temp.getTime temp runtime {
				totalTime += runtime;
				temp.setTime(temp.getTime() - runtime);
				entries.add(temp);
			} totalTime += runtime totalTime runtime temp.setTime(temp.getTime() - runtime) temp.setTime temp temp.getTime() - runtime temp.getTime() temp.getTime temp runtime entries.add(temp) entries.add entries temp {
				totalTime += temp.getTime();
				System.out.println(temp.getName() + " " + totalTime);
			} totalTime += temp.getTime() totalTime temp.getTime() temp.getTime temp System.out.println(temp.getName() + " " + totalTime) System.out.println System.out System System.out temp.getName() + " " + totalTime temp.getName() + " " + totalTime temp.getName() temp.getName temp " " totalTime String args[] args class Process{
	String name;
	int time;
	
	public Process(String n, int t) {
		this.name = n;
		this.time = t;
	}
	
	public int getTime() {
		return this.time; 
	}
	
	public void setTime(int t) {
		this.time = t;
	}
	
	public String getName() {
		return this.name;
	}
} Process String name; name int time; time public Process(String n, int t) {
		this.name = n;
		this.time = t;
	} Process {
		this.name = n;
		this.time = t;
	} this.name = n this.name this this.name n this.time = t this.time this this.time t String n n int t t public int getTime() {
		return this.time; 
	} getTime {
		return this.time; 
	} return this.time; this.time this this.time public void setTime(int t) {
		this.time = t;
	} setTime {
		this.time = t;
	} this.time = t this.time this this.time t int t t public String getName() {
		return this.name;
	} getName {
		return this.name;
	} return this.name; this.name this this.name public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String[] info = sc.nextLine().split(" ");
		Queue<Process> entries = new LinkedList<>();
		int size = Integer.parseInt(info[0]);
		int runtime = Integer.parseInt(info[1]);
		for(int i = 0; i < size; i++) {
			info = sc.nextLine().split(" ");
			entries.add(new Process(info[0], Integer.parseInt(info[1])));
		}
		sc.close();
		int totalTime = 0;
		while(entries.size() > 0) {
			Process temp = entries.remove();
			if(temp.getTime() > runtime) {
				totalTime += runtime;
				temp.setTime(temp.getTime() - runtime);
				entries.add(temp);
			}
			else {
				totalTime += temp.getTime();
				System.out.println(temp.getName() + " " + totalTime);
			}
		}
	}
} public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String[] info = sc.nextLine().split(" ");
		Queue<Process> entries = new LinkedList<>();
		int size = Integer.parseInt(info[0]);
		int runtime = Integer.parseInt(info[1]);
		for(int i = 0; i < size; i++) {
			info = sc.nextLine().split(" ");
			entries.add(new Process(info[0], Integer.parseInt(info[1])));
		}
		sc.close();
		int totalTime = 0;
		while(entries.size() > 0) {
			Process temp = entries.remove();
			if(temp.getTime() > runtime) {
				totalTime += runtime;
				temp.setTime(temp.getTime() - runtime);
				entries.add(temp);
			}
			else {
				totalTime += temp.getTime();
				System.out.println(temp.getName() + " " + totalTime);
			}
		}
	}
} Main
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String[] info = sc.nextLine().split(" ");
		Queue<Process> entries = new LinkedList<>();
		int size = Integer.parseInt(info[0]);
		int runtime = Integer.parseInt(info[1]);
		for(int i = 0; i < size; i++) {
			info = sc.nextLine().split(" ");
			entries.add(new Process(info[0], Integer.parseInt(info[1])));
		}
		sc.close();
		int totalTime = 0;
		while(entries.size() > 0) {
			Process temp = entries.remove();
			if(temp.getTime() > runtime) {
				totalTime += runtime;
				temp.setTime(temp.getTime() - runtime);
				entries.add(temp);
			}
			else {
				totalTime += temp.getTime();
				System.out.println(temp.getName() + " " + totalTime);
			}
		}
	}
}

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

