import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.Queue;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String line = br.readLine();
		String[] arr = line.split(" ");
		int n = Integer.parseInt(arr[0]);
		int q = Integer.parseInt(arr[1]);

		Queue<Process> queue = new LinkedList<Process>();
		for (int i = 0; i < n; i++) {
			line = br.readLine();
			arr = line.split(" ");
			Process p = new Process();
			p.name = arr[0];
			p.time = Integer.parseInt(arr[1]);
			queue.offer(p);
		}

		int passed = 0;
		while (queue.size() > 0) {
			Process p = queue.poll();
			if (p.time <= q) {
				passed += p.time;
				System.out.println(p.name + ' ' + passed);
			} else {
				passed += q;
				p.time -= q;
				queue.offer(p);
			}
		}

		if (br != null) {
			br.close();
			br = null;
		}
	}

	private static class Process {
		public String name;
		public int time;
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.LinkedList; LinkedList java.util import java.util.Queue; Queue java.util public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String line = br.readLine();
		String[] arr = line.split(" ");
		int n = Integer.parseInt(arr[0]);
		int q = Integer.parseInt(arr[1]);

		Queue<Process> queue = new LinkedList<Process>();
		for (int i = 0; i < n; i++) {
			line = br.readLine();
			arr = line.split(" ");
			Process p = new Process();
			p.name = arr[0];
			p.time = Integer.parseInt(arr[1]);
			queue.offer(p);
		}

		int passed = 0;
		while (queue.size() > 0) {
			Process p = queue.poll();
			if (p.time <= q) {
				passed += p.time;
				System.out.println(p.name + ' ' + passed);
			} else {
				passed += q;
				p.time -= q;
				queue.offer(p);
			}
		}

		if (br != null) {
			br.close();
			br = null;
		}
	}

	private static class Process {
		public String name;
		public int time;
	}
} Main public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String line = br.readLine();
		String[] arr = line.split(" ");
		int n = Integer.parseInt(arr[0]);
		int q = Integer.parseInt(arr[1]);

		Queue<Process> queue = new LinkedList<Process>();
		for (int i = 0; i < n; i++) {
			line = br.readLine();
			arr = line.split(" ");
			Process p = new Process();
			p.name = arr[0];
			p.time = Integer.parseInt(arr[1]);
			queue.offer(p);
		}

		int passed = 0;
		while (queue.size() > 0) {
			Process p = queue.poll();
			if (p.time <= q) {
				passed += p.time;
				System.out.println(p.name + ' ' + passed);
			} else {
				passed += q;
				p.time -= q;
				queue.offer(p);
			}
		}

		if (br != null) {
			br.close();
			br = null;
		}
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String line = br.readLine();
		String[] arr = line.split(" ");
		int n = Integer.parseInt(arr[0]);
		int q = Integer.parseInt(arr[1]);

		Queue<Process> queue = new LinkedList<Process>();
		for (int i = 0; i < n; i++) {
			line = br.readLine();
			arr = line.split(" ");
			Process p = new Process();
			p.name = arr[0];
			p.time = Integer.parseInt(arr[1]);
			queue.offer(p);
		}

		int passed = 0;
		while (queue.size() > 0) {
			Process p = queue.poll();
			if (p.time <= q) {
				passed += p.time;
				System.out.println(p.name + ' ' + passed);
			} else {
				passed += q;
				p.time -= q;
				queue.offer(p);
			}
		}

		if (br != null) {
			br.close();
			br = null;
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String line = br.readLine(); line br.readLine() br.readLine br String[] arr = line.split(" "); arr line.split(" ") line.split line " " int n = Integer.parseInt(arr[0]); n Integer.parseInt(arr[0]) Integer.parseInt Integer arr[0] arr 0 int q = Integer.parseInt(arr[1]); q Integer.parseInt(arr[1]) Integer.parseInt Integer arr[1] arr 1 Queue<Process> queue = new LinkedList<Process>(); queue new LinkedList<Process>() for (int i = 0; i < n; i++) {
			line = br.readLine();
			arr = line.split(" ");
			Process p = new Process();
			p.name = arr[0];
			p.time = Integer.parseInt(arr[1]);
			queue.offer(p);
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			line = br.readLine();
			arr = line.split(" ");
			Process p = new Process();
			p.name = arr[0];
			p.time = Integer.parseInt(arr[1]);
			queue.offer(p);
		} {
			line = br.readLine();
			arr = line.split(" ");
			Process p = new Process();
			p.name = arr[0];
			p.time = Integer.parseInt(arr[1]);
			queue.offer(p);
		} line = br.readLine() line br.readLine() br.readLine br arr = line.split(" ") arr line.split(" ") line.split line " " Process p = new Process(); p new Process() p.name = arr[0] p.name p p.name arr[0] arr 0 p.time = Integer.parseInt(arr[1]) p.time p p.time Integer.parseInt(arr[1]) Integer.parseInt Integer arr[1] arr 1 queue.offer(p) queue.offer queue p int passed = 0; passed 0 while (queue.size() > 0) {
			Process p = queue.poll();
			if (p.time <= q) {
				passed += p.time;
				System.out.println(p.name + ' ' + passed);
			} else {
				passed += q;
				p.time -= q;
				queue.offer(p);
			}
		} queue.size() > 0 queue.size() queue.size queue 0 {
			Process p = queue.poll();
			if (p.time <= q) {
				passed += p.time;
				System.out.println(p.name + ' ' + passed);
			} else {
				passed += q;
				p.time -= q;
				queue.offer(p);
			}
		} Process p = queue.poll(); p queue.poll() queue.poll queue if (p.time <= q) {
				passed += p.time;
				System.out.println(p.name + ' ' + passed);
			} else {
				passed += q;
				p.time -= q;
				queue.offer(p);
			} p.time <= q p.time p p.time q {
				passed += p.time;
				System.out.println(p.name + ' ' + passed);
			} passed += p.time passed p.time p p.time System.out.println(p.name + ' ' + passed) System.out.println System.out System System.out p.name + ' ' + passed p.name + ' ' + passed p.name p p.name ' ' passed {
				passed += q;
				p.time -= q;
				queue.offer(p);
			} passed += q passed q p.time -= q p.time p p.time q queue.offer(p) queue.offer queue p if (br != null) {
			br.close();
			br = null;
		} br != null br null {
			br.close();
			br = null;
		} br.close() br.close br br = null br null String[] args args private static class Process {
		public String name;
		public int time;
	} Process public String name; name public int time; time public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String line = br.readLine();
		String[] arr = line.split(" ");
		int n = Integer.parseInt(arr[0]);
		int q = Integer.parseInt(arr[1]);

		Queue<Process> queue = new LinkedList<Process>();
		for (int i = 0; i < n; i++) {
			line = br.readLine();
			arr = line.split(" ");
			Process p = new Process();
			p.name = arr[0];
			p.time = Integer.parseInt(arr[1]);
			queue.offer(p);
		}

		int passed = 0;
		while (queue.size() > 0) {
			Process p = queue.poll();
			if (p.time <= q) {
				passed += p.time;
				System.out.println(p.name + ' ' + passed);
			} else {
				passed += q;
				p.time -= q;
				queue.offer(p);
			}
		}

		if (br != null) {
			br.close();
			br = null;
		}
	}

	private static class Process {
		public String name;
		public int time;
	}
} public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String line = br.readLine();
		String[] arr = line.split(" ");
		int n = Integer.parseInt(arr[0]);
		int q = Integer.parseInt(arr[1]);

		Queue<Process> queue = new LinkedList<Process>();
		for (int i = 0; i < n; i++) {
			line = br.readLine();
			arr = line.split(" ");
			Process p = new Process();
			p.name = arr[0];
			p.time = Integer.parseInt(arr[1]);
			queue.offer(p);
		}

		int passed = 0;
		while (queue.size() > 0) {
			Process p = queue.poll();
			if (p.time <= q) {
				passed += p.time;
				System.out.println(p.name + ' ' + passed);
			} else {
				passed += q;
				p.time -= q;
				queue.offer(p);
			}
		}

		if (br != null) {
			br.close();
			br = null;
		}
	}

	private static class Process {
		public String name;
		public int time;
	}
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.Queue;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String line = br.readLine();
		String[] arr = line.split(" ");
		int n = Integer.parseInt(arr[0]);
		int q = Integer.parseInt(arr[1]);

		Queue<Process> queue = new LinkedList<Process>();
		for (int i = 0; i < n; i++) {
			line = br.readLine();
			arr = line.split(" ");
			Process p = new Process();
			p.name = arr[0];
			p.time = Integer.parseInt(arr[1]);
			queue.offer(p);
		}

		int passed = 0;
		while (queue.size() > 0) {
			Process p = queue.poll();
			if (p.time <= q) {
				passed += p.time;
				System.out.println(p.name + ' ' + passed);
			} else {
				passed += q;
				p.time -= q;
				queue.offer(p);
			}
		}

		if (br != null) {
			br.close();
			br = null;
		}
	}

	private static class Process {
		public String name;
		public int time;
	}
}