import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int time = scanner.nextInt();
		int total=0;
		Deque<Integer> queue = new ArrayDeque<Integer>();
		Deque<String> name = new ArrayDeque<String>();
		for (int i = 0; i < n; i++) {
			name.add(scanner.next());
			queue.add(scanner.nextInt());
		}
		while(true) {
			int num=queue.poll();
			String name1=name.poll();
			num=num-time;
			if(num<=0) {
				total=total+time+num;
				System.out.print(name1+" ");
				System.out.println(total);
				if(name.isEmpty()) {
					break;
				}
			}else {
				total=total+time;
				queue.add(num);
				name.add(name1);
			}
		}
		scanner.close();
	}

}
 import java.util.ArrayDeque; ArrayDeque java.util import java.util.Deque; Deque java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int time = scanner.nextInt();
		int total=0;
		Deque<Integer> queue = new ArrayDeque<Integer>();
		Deque<String> name = new ArrayDeque<String>();
		for (int i = 0; i < n; i++) {
			name.add(scanner.next());
			queue.add(scanner.nextInt());
		}
		while(true) {
			int num=queue.poll();
			String name1=name.poll();
			num=num-time;
			if(num<=0) {
				total=total+time+num;
				System.out.print(name1+" ");
				System.out.println(total);
				if(name.isEmpty()) {
					break;
				}
			}else {
				total=total+time;
				queue.add(num);
				name.add(name1);
			}
		}
		scanner.close();
	}

} Main public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int time = scanner.nextInt();
		int total=0;
		Deque<Integer> queue = new ArrayDeque<Integer>();
		Deque<String> name = new ArrayDeque<String>();
		for (int i = 0; i < n; i++) {
			name.add(scanner.next());
			queue.add(scanner.nextInt());
		}
		while(true) {
			int num=queue.poll();
			String name1=name.poll();
			num=num-time;
			if(num<=0) {
				total=total+time+num;
				System.out.print(name1+" ");
				System.out.println(total);
				if(name.isEmpty()) {
					break;
				}
			}else {
				total=total+time;
				queue.add(num);
				name.add(name1);
			}
		}
		scanner.close();
	} main {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int time = scanner.nextInt();
		int total=0;
		Deque<Integer> queue = new ArrayDeque<Integer>();
		Deque<String> name = new ArrayDeque<String>();
		for (int i = 0; i < n; i++) {
			name.add(scanner.next());
			queue.add(scanner.nextInt());
		}
		while(true) {
			int num=queue.poll();
			String name1=name.poll();
			num=num-time;
			if(num<=0) {
				total=total+time+num;
				System.out.print(name1+" ");
				System.out.println(total);
				if(name.isEmpty()) {
					break;
				}
			}else {
				total=total+time;
				queue.add(num);
				name.add(name1);
			}
		}
		scanner.close();
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner int time = scanner.nextInt(); time scanner.nextInt() scanner.nextInt scanner int total=0; total 0 Deque<Integer> queue = new ArrayDeque<Integer>(); queue new ArrayDeque<Integer>() Deque<String> name = new ArrayDeque<String>(); name new ArrayDeque<String>() for (int i = 0; i < n; i++) {
			name.add(scanner.next());
			queue.add(scanner.nextInt());
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			name.add(scanner.next());
			queue.add(scanner.nextInt());
		} {
			name.add(scanner.next());
			queue.add(scanner.nextInt());
		} name.add(scanner.next()) name.add name scanner.next() scanner.next scanner queue.add(scanner.nextInt()) queue.add queue scanner.nextInt() scanner.nextInt scanner while(true) {
			int num=queue.poll();
			String name1=name.poll();
			num=num-time;
			if(num<=0) {
				total=total+time+num;
				System.out.print(name1+" ");
				System.out.println(total);
				if(name.isEmpty()) {
					break;
				}
			}else {
				total=total+time;
				queue.add(num);
				name.add(name1);
			}
		} true {
			int num=queue.poll();
			String name1=name.poll();
			num=num-time;
			if(num<=0) {
				total=total+time+num;
				System.out.print(name1+" ");
				System.out.println(total);
				if(name.isEmpty()) {
					break;
				}
			}else {
				total=total+time;
				queue.add(num);
				name.add(name1);
			}
		} int num=queue.poll(); num queue.poll() queue.poll queue String name1=name.poll(); name1 name.poll() name.poll name num=num-time num num-time num time if(num<=0) {
				total=total+time+num;
				System.out.print(name1+" ");
				System.out.println(total);
				if(name.isEmpty()) {
					break;
				}
			}else {
				total=total+time;
				queue.add(num);
				name.add(name1);
			} num<=0 num 0 {
				total=total+time+num;
				System.out.print(name1+" ");
				System.out.println(total);
				if(name.isEmpty()) {
					break;
				}
			} total=total+time+num total total+time+num total+time+num total time num System.out.print(name1+" ") System.out.print System.out System System.out name1+" " name1 " " System.out.println(total) System.out.println System.out System System.out total if(name.isEmpty()) {
					break;
				} name.isEmpty() name.isEmpty name {
					break;
				} break; {
				total=total+time;
				queue.add(num);
				name.add(name1);
			} total=total+time total total+time total time queue.add(num) queue.add queue num name.add(name1) name.add name name1 scanner.close() scanner.close scanner String[] args args public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int time = scanner.nextInt();
		int total=0;
		Deque<Integer> queue = new ArrayDeque<Integer>();
		Deque<String> name = new ArrayDeque<String>();
		for (int i = 0; i < n; i++) {
			name.add(scanner.next());
			queue.add(scanner.nextInt());
		}
		while(true) {
			int num=queue.poll();
			String name1=name.poll();
			num=num-time;
			if(num<=0) {
				total=total+time+num;
				System.out.print(name1+" ");
				System.out.println(total);
				if(name.isEmpty()) {
					break;
				}
			}else {
				total=total+time;
				queue.add(num);
				name.add(name1);
			}
		}
		scanner.close();
	}

} public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int time = scanner.nextInt();
		int total=0;
		Deque<Integer> queue = new ArrayDeque<Integer>();
		Deque<String> name = new ArrayDeque<String>();
		for (int i = 0; i < n; i++) {
			name.add(scanner.next());
			queue.add(scanner.nextInt());
		}
		while(true) {
			int num=queue.poll();
			String name1=name.poll();
			num=num-time;
			if(num<=0) {
				total=total+time+num;
				System.out.print(name1+" ");
				System.out.println(total);
				if(name.isEmpty()) {
					break;
				}
			}else {
				total=total+time;
				queue.add(num);
				name.add(name1);
			}
		}
		scanner.close();
	}

} Main
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int time = scanner.nextInt();
		int total=0;
		Deque<Integer> queue = new ArrayDeque<Integer>();
		Deque<String> name = new ArrayDeque<String>();
		for (int i = 0; i < n; i++) {
			name.add(scanner.next());
			queue.add(scanner.nextInt());
		}
		while(true) {
			int num=queue.poll();
			String name1=name.poll();
			num=num-time;
			if(num<=0) {
				total=total+time+num;
				System.out.print(name1+" ");
				System.out.println(total);
				if(name.isEmpty()) {
					break;
				}
			}else {
				total=total+time;
				queue.add(num);
				name.add(name1);
			}
		}
		scanner.close();
	}

}

