import java.util.*;

public class Main {
	public static void main(String[] args) {
		class Combo {
			String name;
			long time;
		}
		
		Queue<Combo> remain = new LinkedList<Combo>();		
		Scanner scanner = new Scanner(System.in);
		
		long n = scanner.nextLong();
		long q = scanner.nextLong();
				
		for (int i = 0; i < n; i ++) {
			Combo process = new Combo();
			process.name = scanner.next();
			process.time = scanner.nextLong();
			remain.add(process);
		}
		scanner.close();
		

		long GlobeTime = 0;
		
		while (remain.size() > 0) {
			Combo currentProcess = remain.remove();
			
			if (currentProcess.time <= q) {
				GlobeTime += currentProcess.time;
				System.out.println(currentProcess.name + " " + GlobeTime);
			} else {
				currentProcess.time -= q;
				GlobeTime += q;
				remain.add(currentProcess);
			}
		}
		
	}
}  import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		class Combo {
			String name;
			long time;
		}
		
		Queue<Combo> remain = new LinkedList<Combo>();		
		Scanner scanner = new Scanner(System.in);
		
		long n = scanner.nextLong();
		long q = scanner.nextLong();
				
		for (int i = 0; i < n; i ++) {
			Combo process = new Combo();
			process.name = scanner.next();
			process.time = scanner.nextLong();
			remain.add(process);
		}
		scanner.close();
		

		long GlobeTime = 0;
		
		while (remain.size() > 0) {
			Combo currentProcess = remain.remove();
			
			if (currentProcess.time <= q) {
				GlobeTime += currentProcess.time;
				System.out.println(currentProcess.name + " " + GlobeTime);
			} else {
				currentProcess.time -= q;
				GlobeTime += q;
				remain.add(currentProcess);
			}
		}
		
	}
} Main public static void main(String[] args) {
		class Combo {
			String name;
			long time;
		}
		
		Queue<Combo> remain = new LinkedList<Combo>();		
		Scanner scanner = new Scanner(System.in);
		
		long n = scanner.nextLong();
		long q = scanner.nextLong();
				
		for (int i = 0; i < n; i ++) {
			Combo process = new Combo();
			process.name = scanner.next();
			process.time = scanner.nextLong();
			remain.add(process);
		}
		scanner.close();
		

		long GlobeTime = 0;
		
		while (remain.size() > 0) {
			Combo currentProcess = remain.remove();
			
			if (currentProcess.time <= q) {
				GlobeTime += currentProcess.time;
				System.out.println(currentProcess.name + " " + GlobeTime);
			} else {
				currentProcess.time -= q;
				GlobeTime += q;
				remain.add(currentProcess);
			}
		}
		
	} main {
		class Combo {
			String name;
			long time;
		}
		
		Queue<Combo> remain = new LinkedList<Combo>();		
		Scanner scanner = new Scanner(System.in);
		
		long n = scanner.nextLong();
		long q = scanner.nextLong();
				
		for (int i = 0; i < n; i ++) {
			Combo process = new Combo();
			process.name = scanner.next();
			process.time = scanner.nextLong();
			remain.add(process);
		}
		scanner.close();
		

		long GlobeTime = 0;
		
		while (remain.size() > 0) {
			Combo currentProcess = remain.remove();
			
			if (currentProcess.time <= q) {
				GlobeTime += currentProcess.time;
				System.out.println(currentProcess.name + " " + GlobeTime);
			} else {
				currentProcess.time -= q;
				GlobeTime += q;
				remain.add(currentProcess);
			}
		}
		
	} Queue<Combo> remain = new LinkedList<Combo>(); remain new LinkedList<Combo>() Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) long n = scanner.nextLong(); n scanner.nextLong() scanner.nextLong scanner long q = scanner.nextLong(); q scanner.nextLong() scanner.nextLong scanner for (int i = 0; i < n; i ++) {
			Combo process = new Combo();
			process.name = scanner.next();
			process.time = scanner.nextLong();
			remain.add(process);
		} int i = 0; int i = 0; i 0 i < n i n i ++ i ++ i {
			Combo process = new Combo();
			process.name = scanner.next();
			process.time = scanner.nextLong();
			remain.add(process);
		} {
			Combo process = new Combo();
			process.name = scanner.next();
			process.time = scanner.nextLong();
			remain.add(process);
		} Combo process = new Combo(); process new Combo() process.name = scanner.next() process.name process process.name scanner.next() scanner.next scanner process.time = scanner.nextLong() process.time process process.time scanner.nextLong() scanner.nextLong scanner remain.add(process) remain.add remain process scanner.close() scanner.close scanner long GlobeTime = 0; GlobeTime 0 while (remain.size() > 0) {
			Combo currentProcess = remain.remove();
			
			if (currentProcess.time <= q) {
				GlobeTime += currentProcess.time;
				System.out.println(currentProcess.name + " " + GlobeTime);
			} else {
				currentProcess.time -= q;
				GlobeTime += q;
				remain.add(currentProcess);
			}
		} remain.size() > 0 remain.size() remain.size remain 0 {
			Combo currentProcess = remain.remove();
			
			if (currentProcess.time <= q) {
				GlobeTime += currentProcess.time;
				System.out.println(currentProcess.name + " " + GlobeTime);
			} else {
				currentProcess.time -= q;
				GlobeTime += q;
				remain.add(currentProcess);
			}
		} Combo currentProcess = remain.remove(); currentProcess remain.remove() remain.remove remain if (currentProcess.time <= q) {
				GlobeTime += currentProcess.time;
				System.out.println(currentProcess.name + " " + GlobeTime);
			} else {
				currentProcess.time -= q;
				GlobeTime += q;
				remain.add(currentProcess);
			} currentProcess.time <= q currentProcess.time currentProcess currentProcess.time q {
				GlobeTime += currentProcess.time;
				System.out.println(currentProcess.name + " " + GlobeTime);
			} GlobeTime += currentProcess.time GlobeTime currentProcess.time currentProcess currentProcess.time System.out.println(currentProcess.name + " " + GlobeTime) System.out.println System.out System System.out currentProcess.name + " " + GlobeTime currentProcess.name + " " + GlobeTime currentProcess.name currentProcess currentProcess.name " " GlobeTime {
				currentProcess.time -= q;
				GlobeTime += q;
				remain.add(currentProcess);
			} currentProcess.time -= q currentProcess.time currentProcess currentProcess.time q GlobeTime += q GlobeTime q remain.add(currentProcess) remain.add remain currentProcess String[] args args public class Main {
	public static void main(String[] args) {
		class Combo {
			String name;
			long time;
		}
		
		Queue<Combo> remain = new LinkedList<Combo>();		
		Scanner scanner = new Scanner(System.in);
		
		long n = scanner.nextLong();
		long q = scanner.nextLong();
				
		for (int i = 0; i < n; i ++) {
			Combo process = new Combo();
			process.name = scanner.next();
			process.time = scanner.nextLong();
			remain.add(process);
		}
		scanner.close();
		

		long GlobeTime = 0;
		
		while (remain.size() > 0) {
			Combo currentProcess = remain.remove();
			
			if (currentProcess.time <= q) {
				GlobeTime += currentProcess.time;
				System.out.println(currentProcess.name + " " + GlobeTime);
			} else {
				currentProcess.time -= q;
				GlobeTime += q;
				remain.add(currentProcess);
			}
		}
		
	}
} public class Main {
	public static void main(String[] args) {
		class Combo {
			String name;
			long time;
		}
		
		Queue<Combo> remain = new LinkedList<Combo>();		
		Scanner scanner = new Scanner(System.in);
		
		long n = scanner.nextLong();
		long q = scanner.nextLong();
				
		for (int i = 0; i < n; i ++) {
			Combo process = new Combo();
			process.name = scanner.next();
			process.time = scanner.nextLong();
			remain.add(process);
		}
		scanner.close();
		

		long GlobeTime = 0;
		
		while (remain.size() > 0) {
			Combo currentProcess = remain.remove();
			
			if (currentProcess.time <= q) {
				GlobeTime += currentProcess.time;
				System.out.println(currentProcess.name + " " + GlobeTime);
			} else {
				currentProcess.time -= q;
				GlobeTime += q;
				remain.add(currentProcess);
			}
		}
		
	}
} Main
import java.util.*;

public class Main {
	public static void main(String[] args) {
		class Combo {
			String name;
			long time;
		}
		
		Queue<Combo> remain = new LinkedList<Combo>();		
		Scanner scanner = new Scanner(System.in);
		
		long n = scanner.nextLong();
		long q = scanner.nextLong();
				
		for (int i = 0; i < n; i ++) {
			Combo process = new Combo();
			process.name = scanner.next();
			process.time = scanner.nextLong();
			remain.add(process);
		}
		scanner.close();
		

		long GlobeTime = 0;
		
		while (remain.size() > 0) {
			Combo currentProcess = remain.remove();
			
			if (currentProcess.time <= q) {
				GlobeTime += currentProcess.time;
				System.out.println(currentProcess.name + " " + GlobeTime);
			} else {
				currentProcess.time -= q;
				GlobeTime += q;
				remain.add(currentProcess);
			}
		}
		
	}
} 
