import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

		public Process(String name, int time) {
			this.name = name;
			this.time = time;
		}

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

		public String getName() {
			return this.name;
		}

		public int getTime() {
			return this.time;
		}
	}

	public static class Queue {
		private Process[] data;
		private int head;
		private int tail;
		private int max;

		public Queue (int processNum) {
			this.data = new Process[processNum + 1];
			this.head = 0;
			this.tail = 0;
			this.max = processNum + 1;
		}

		public void enqueue(Process process) {
			this.data[this.tail] = process;
			if(this.tail + 1 == this.max) {
				this.tail = 0;
			} else {
				this.tail++;
			}
		}

		public Process dequeue() {
			Process process = this.data[this.head];
			if(this.head + 1 == this.max) {
				this.head = 0;
			} else {
				this.head++;
			}
			return process;
		}

		public boolean isEmpty() {
			if(this.tail == this.head) {
				return true;
			}
			return false;
		}
	}

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

		String[] premise = br.readLine().split(" ");

		int processNum =Integer.parseInt(premise[0]);

		Queue queue = new Queue(processNum);

		int q = Integer.parseInt(premise[1]);

		for(int i = 0; i < processNum; i++) {
			String[] processString = br.readLine().split(" ");
			Process process = new Process(processString[0], Integer.parseInt(processString[1]));
			queue.enqueue(process);
		}

		int progressTime = 0;
		while(!queue.isEmpty()) {
			Process process = queue.dequeue();

			if(process.getTime() <= q) {
				progressTime += process.getTime();
				System.out.println(process.getName() + " " + progressTime);
			} else {

				// ?????????????????????1??\???????????´???
				int processingTime = process.getTime() - q;

				progressTime += q;

				process.setTime(processingTime);
				queue.enqueue(process);
			}
		}
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

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

		public Process(String name, int time) {
			this.name = name;
			this.time = time;
		}

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

		public String getName() {
			return this.name;
		}

		public int getTime() {
			return this.time;
		}
	}

	public static class Queue {
		private Process[] data;
		private int head;
		private int tail;
		private int max;

		public Queue (int processNum) {
			this.data = new Process[processNum + 1];
			this.head = 0;
			this.tail = 0;
			this.max = processNum + 1;
		}

		public void enqueue(Process process) {
			this.data[this.tail] = process;
			if(this.tail + 1 == this.max) {
				this.tail = 0;
			} else {
				this.tail++;
			}
		}

		public Process dequeue() {
			Process process = this.data[this.head];
			if(this.head + 1 == this.max) {
				this.head = 0;
			} else {
				this.head++;
			}
			return process;
		}

		public boolean isEmpty() {
			if(this.tail == this.head) {
				return true;
			}
			return false;
		}
	}

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

		String[] premise = br.readLine().split(" ");

		int processNum =Integer.parseInt(premise[0]);

		Queue queue = new Queue(processNum);

		int q = Integer.parseInt(premise[1]);

		for(int i = 0; i < processNum; i++) {
			String[] processString = br.readLine().split(" ");
			Process process = new Process(processString[0], Integer.parseInt(processString[1]));
			queue.enqueue(process);
		}

		int progressTime = 0;
		while(!queue.isEmpty()) {
			Process process = queue.dequeue();

			if(process.getTime() <= q) {
				progressTime += process.getTime();
				System.out.println(process.getName() + " " + progressTime);
			} else {

				// ?????????????????????1??\???????????´???
				int processingTime = process.getTime() - q;

				progressTime += q;

				process.setTime(processingTime);
				queue.enqueue(process);
			}
		}
	}
} Main public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] premise = br.readLine().split(" ");

		int processNum =Integer.parseInt(premise[0]);

		Queue queue = new Queue(processNum);

		int q = Integer.parseInt(premise[1]);

		for(int i = 0; i < processNum; i++) {
			String[] processString = br.readLine().split(" ");
			Process process = new Process(processString[0], Integer.parseInt(processString[1]));
			queue.enqueue(process);
		}

		int progressTime = 0;
		while(!queue.isEmpty()) {
			Process process = queue.dequeue();

			if(process.getTime() <= q) {
				progressTime += process.getTime();
				System.out.println(process.getName() + " " + progressTime);
			} else {

				// ?????????????????????1??\???????????´???
				int processingTime = process.getTime() - q;

				progressTime += q;

				process.setTime(processingTime);
				queue.enqueue(process);
			}
		}
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] premise = br.readLine().split(" ");

		int processNum =Integer.parseInt(premise[0]);

		Queue queue = new Queue(processNum);

		int q = Integer.parseInt(premise[1]);

		for(int i = 0; i < processNum; i++) {
			String[] processString = br.readLine().split(" ");
			Process process = new Process(processString[0], Integer.parseInt(processString[1]));
			queue.enqueue(process);
		}

		int progressTime = 0;
		while(!queue.isEmpty()) {
			Process process = queue.dequeue();

			if(process.getTime() <= q) {
				progressTime += process.getTime();
				System.out.println(process.getName() + " " + progressTime);
			} else {

				// ?????????????????????1??\???????????´???
				int processingTime = process.getTime() - q;

				progressTime += q;

				process.setTime(processingTime);
				queue.enqueue(process);
			}
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] premise = br.readLine().split(" "); premise br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int processNum =Integer.parseInt(premise[0]); processNum Integer.parseInt(premise[0]) Integer.parseInt Integer premise[0] premise 0 Queue queue = new Queue(processNum); queue new Queue(processNum) int q = Integer.parseInt(premise[1]); q Integer.parseInt(premise[1]) Integer.parseInt Integer premise[1] premise 1 for(int i = 0; i < processNum; i++) {
			String[] processString = br.readLine().split(" ");
			Process process = new Process(processString[0], Integer.parseInt(processString[1]));
			queue.enqueue(process);
		} int i = 0; int i = 0; i 0 i < processNum i processNum i++ i++ i {
			String[] processString = br.readLine().split(" ");
			Process process = new Process(processString[0], Integer.parseInt(processString[1]));
			queue.enqueue(process);
		} {
			String[] processString = br.readLine().split(" ");
			Process process = new Process(processString[0], Integer.parseInt(processString[1]));
			queue.enqueue(process);
		} String[] processString = br.readLine().split(" "); processString br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " Process process = new Process(processString[0], Integer.parseInt(processString[1])); process new Process(processString[0], Integer.parseInt(processString[1])) queue.enqueue(process) queue.enqueue queue process int progressTime = 0; progressTime 0 while(!queue.isEmpty()) {
			Process process = queue.dequeue();

			if(process.getTime() <= q) {
				progressTime += process.getTime();
				System.out.println(process.getName() + " " + progressTime);
			} else {

				// ?????????????????????1??\???????????´???
				int processingTime = process.getTime() - q;

				progressTime += q;

				process.setTime(processingTime);
				queue.enqueue(process);
			}
		} !queue.isEmpty() queue.isEmpty() queue.isEmpty queue {
			Process process = queue.dequeue();

			if(process.getTime() <= q) {
				progressTime += process.getTime();
				System.out.println(process.getName() + " " + progressTime);
			} else {

				// ?????????????????????1??\???????????´???
				int processingTime = process.getTime() - q;

				progressTime += q;

				process.setTime(processingTime);
				queue.enqueue(process);
			}
		} Process process = queue.dequeue(); process queue.dequeue() queue.dequeue queue if(process.getTime() <= q) {
				progressTime += process.getTime();
				System.out.println(process.getName() + " " + progressTime);
			} else {

				// ?????????????????????1??\???????????´???
				int processingTime = process.getTime() - q;

				progressTime += q;

				process.setTime(processingTime);
				queue.enqueue(process);
			} process.getTime() <= q process.getTime() process.getTime process q {
				progressTime += process.getTime();
				System.out.println(process.getName() + " " + progressTime);
			} progressTime += process.getTime() progressTime process.getTime() process.getTime process System.out.println(process.getName() + " " + progressTime) System.out.println System.out System System.out process.getName() + " " + progressTime process.getName() + " " + progressTime process.getName() process.getName process " " progressTime {

				// ?????????????????????1??\???????????´???
				int processingTime = process.getTime() - q;

				progressTime += q;

				process.setTime(processingTime);
				queue.enqueue(process);
			} int processingTime = process.getTime() - q; processingTime process.getTime() - q process.getTime() process.getTime process q progressTime += q progressTime q process.setTime(processingTime) process.setTime process processingTime queue.enqueue(process) queue.enqueue queue process String[] args args public static class Process {
		private String name;
		private int time;

		public Process(String name, int time) {
			this.name = name;
			this.time = time;
		}

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

		public String getName() {
			return this.name;
		}

		public int getTime() {
			return this.time;
		}
	} 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 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 this.name;
		} getName {
			return this.name;
		} return this.name; this.name this this.name public int getTime() {
			return this.time;
		} getTime {
			return this.time;
		} return this.time; this.time this this.time public static class Queue {
		private Process[] data;
		private int head;
		private int tail;
		private int max;

		public Queue (int processNum) {
			this.data = new Process[processNum + 1];
			this.head = 0;
			this.tail = 0;
			this.max = processNum + 1;
		}

		public void enqueue(Process process) {
			this.data[this.tail] = process;
			if(this.tail + 1 == this.max) {
				this.tail = 0;
			} else {
				this.tail++;
			}
		}

		public Process dequeue() {
			Process process = this.data[this.head];
			if(this.head + 1 == this.max) {
				this.head = 0;
			} else {
				this.head++;
			}
			return process;
		}

		public boolean isEmpty() {
			if(this.tail == this.head) {
				return true;
			}
			return false;
		}
	} Queue private Process[] data; data private int head; head private int tail; tail private int max; max public Queue (int processNum) {
			this.data = new Process[processNum + 1];
			this.head = 0;
			this.tail = 0;
			this.max = processNum + 1;
		} Queue {
			this.data = new Process[processNum + 1];
			this.head = 0;
			this.tail = 0;
			this.max = processNum + 1;
		} this.data = new Process[processNum + 1] this.data this this.data new Process[processNum + 1] processNum + 1 processNum 1 this.head = 0 this.head this this.head 0 this.tail = 0 this.tail this this.tail 0 this.max = processNum + 1 this.max this this.max processNum + 1 processNum 1 int processNum processNum public void enqueue(Process process) {
			this.data[this.tail] = process;
			if(this.tail + 1 == this.max) {
				this.tail = 0;
			} else {
				this.tail++;
			}
		} enqueue {
			this.data[this.tail] = process;
			if(this.tail + 1 == this.max) {
				this.tail = 0;
			} else {
				this.tail++;
			}
		} this.data[this.tail] = process this.data[this.tail] this.data this this.data this.tail this this.tail process if(this.tail + 1 == this.max) {
				this.tail = 0;
			} else {
				this.tail++;
			} this.tail + 1 == this.max this.tail + 1 this.tail this this.tail 1 this.max this this.max {
				this.tail = 0;
			} this.tail = 0 this.tail this this.tail 0 {
				this.tail++;
			} this.tail++ this.tail this this.tail Process process process public Process dequeue() {
			Process process = this.data[this.head];
			if(this.head + 1 == this.max) {
				this.head = 0;
			} else {
				this.head++;
			}
			return process;
		} dequeue {
			Process process = this.data[this.head];
			if(this.head + 1 == this.max) {
				this.head = 0;
			} else {
				this.head++;
			}
			return process;
		} Process process = this.data[this.head]; process this.data[this.head] this.data this this.data this.head this this.head if(this.head + 1 == this.max) {
				this.head = 0;
			} else {
				this.head++;
			} this.head + 1 == this.max this.head + 1 this.head this this.head 1 this.max this this.max {
				this.head = 0;
			} this.head = 0 this.head this this.head 0 {
				this.head++;
			} this.head++ this.head this this.head return process; process public boolean isEmpty() {
			if(this.tail == this.head) {
				return true;
			}
			return false;
		} isEmpty {
			if(this.tail == this.head) {
				return true;
			}
			return false;
		} if(this.tail == this.head) {
				return true;
			} this.tail == this.head this.tail this this.tail this.head this this.head {
				return true;
			} return true; true return false; false public class Main {

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

		public Process(String name, int time) {
			this.name = name;
			this.time = time;
		}

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

		public String getName() {
			return this.name;
		}

		public int getTime() {
			return this.time;
		}
	}

	public static class Queue {
		private Process[] data;
		private int head;
		private int tail;
		private int max;

		public Queue (int processNum) {
			this.data = new Process[processNum + 1];
			this.head = 0;
			this.tail = 0;
			this.max = processNum + 1;
		}

		public void enqueue(Process process) {
			this.data[this.tail] = process;
			if(this.tail + 1 == this.max) {
				this.tail = 0;
			} else {
				this.tail++;
			}
		}

		public Process dequeue() {
			Process process = this.data[this.head];
			if(this.head + 1 == this.max) {
				this.head = 0;
			} else {
				this.head++;
			}
			return process;
		}

		public boolean isEmpty() {
			if(this.tail == this.head) {
				return true;
			}
			return false;
		}
	}

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

		String[] premise = br.readLine().split(" ");

		int processNum =Integer.parseInt(premise[0]);

		Queue queue = new Queue(processNum);

		int q = Integer.parseInt(premise[1]);

		for(int i = 0; i < processNum; i++) {
			String[] processString = br.readLine().split(" ");
			Process process = new Process(processString[0], Integer.parseInt(processString[1]));
			queue.enqueue(process);
		}

		int progressTime = 0;
		while(!queue.isEmpty()) {
			Process process = queue.dequeue();

			if(process.getTime() <= q) {
				progressTime += process.getTime();
				System.out.println(process.getName() + " " + progressTime);
			} else {

				// ?????????????????????1??\???????????´???
				int processingTime = process.getTime() - q;

				progressTime += q;

				process.setTime(processingTime);
				queue.enqueue(process);
			}
		}
	}
} public class Main {

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

		public Process(String name, int time) {
			this.name = name;
			this.time = time;
		}

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

		public String getName() {
			return this.name;
		}

		public int getTime() {
			return this.time;
		}
	}

	public static class Queue {
		private Process[] data;
		private int head;
		private int tail;
		private int max;

		public Queue (int processNum) {
			this.data = new Process[processNum + 1];
			this.head = 0;
			this.tail = 0;
			this.max = processNum + 1;
		}

		public void enqueue(Process process) {
			this.data[this.tail] = process;
			if(this.tail + 1 == this.max) {
				this.tail = 0;
			} else {
				this.tail++;
			}
		}

		public Process dequeue() {
			Process process = this.data[this.head];
			if(this.head + 1 == this.max) {
				this.head = 0;
			} else {
				this.head++;
			}
			return process;
		}

		public boolean isEmpty() {
			if(this.tail == this.head) {
				return true;
			}
			return false;
		}
	}

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

		String[] premise = br.readLine().split(" ");

		int processNum =Integer.parseInt(premise[0]);

		Queue queue = new Queue(processNum);

		int q = Integer.parseInt(premise[1]);

		for(int i = 0; i < processNum; i++) {
			String[] processString = br.readLine().split(" ");
			Process process = new Process(processString[0], Integer.parseInt(processString[1]));
			queue.enqueue(process);
		}

		int progressTime = 0;
		while(!queue.isEmpty()) {
			Process process = queue.dequeue();

			if(process.getTime() <= q) {
				progressTime += process.getTime();
				System.out.println(process.getName() + " " + progressTime);
			} else {

				// ?????????????????????1??\???????????´???
				int processingTime = process.getTime() - q;

				progressTime += q;

				process.setTime(processingTime);
				queue.enqueue(process);
			}
		}
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

		public Process(String name, int time) {
			this.name = name;
			this.time = time;
		}

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

		public String getName() {
			return this.name;
		}

		public int getTime() {
			return this.time;
		}
	}

	public static class Queue {
		private Process[] data;
		private int head;
		private int tail;
		private int max;

		public Queue (int processNum) {
			this.data = new Process[processNum + 1];
			this.head = 0;
			this.tail = 0;
			this.max = processNum + 1;
		}

		public void enqueue(Process process) {
			this.data[this.tail] = process;
			if(this.tail + 1 == this.max) {
				this.tail = 0;
			} else {
				this.tail++;
			}
		}

		public Process dequeue() {
			Process process = this.data[this.head];
			if(this.head + 1 == this.max) {
				this.head = 0;
			} else {
				this.head++;
			}
			return process;
		}

		public boolean isEmpty() {
			if(this.tail == this.head) {
				return true;
			}
			return false;
		}
	}

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

		String[] premise = br.readLine().split(" ");

		int processNum =Integer.parseInt(premise[0]);

		Queue queue = new Queue(processNum);

		int q = Integer.parseInt(premise[1]);

		for(int i = 0; i < processNum; i++) {
			String[] processString = br.readLine().split(" ");
			Process process = new Process(processString[0], Integer.parseInt(processString[1]));
			queue.enqueue(process);
		}

		int progressTime = 0;
		while(!queue.isEmpty()) {
			Process process = queue.dequeue();

			if(process.getTime() <= q) {
				progressTime += process.getTime();
				System.out.println(process.getName() + " " + progressTime);
			} else {

				// ?????????????????????1??\???????????´???
				int processingTime = process.getTime() - q;

				progressTime += q;

				process.setTime(processingTime);
				queue.enqueue(process);
			}
		}
	}
}