import java.util.Scanner;
import java.util.ArrayDeque;
import java.util.Queue;
class Main {
    public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String[] t = scan.nextLine().split("\\s");
		int num = Integer.parseInt(t[0]);
		int Dectime = Integer.parseInt(t[1]);
		
		Queue<Process> queue = new ArrayDeque<Process>();
		for(int i = 0; i < num; i++){
			String[] str = scan.nextLine().split("\\s");
			
			Process pro = new Process(str[0], Integer.parseInt(str[1]));
			queue.offer(pro);
		}
		
		int result = 0;
		
		while(queue.size() > 0){
			Process pro = queue.poll();
				
			result += Dectime;
			
			if((pro.time = pro.time - Dectime) > 0){
				queue.offer(pro);
			}else{
				result += pro.time;
				System.out.println(pro.name + " " + result);
			}
			
		}
	}
}

class Process{
	String name = null;
	int time = 0;
	
	Process(String n, int t){
		this.name = n;
		this.time = t;
	}
} import java.util.Scanner; Scanner java.util import java.util.ArrayDeque; ArrayDeque java.util import java.util.Queue; Queue java.util class Main {
    public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String[] t = scan.nextLine().split("\\s");
		int num = Integer.parseInt(t[0]);
		int Dectime = Integer.parseInt(t[1]);
		
		Queue<Process> queue = new ArrayDeque<Process>();
		for(int i = 0; i < num; i++){
			String[] str = scan.nextLine().split("\\s");
			
			Process pro = new Process(str[0], Integer.parseInt(str[1]));
			queue.offer(pro);
		}
		
		int result = 0;
		
		while(queue.size() > 0){
			Process pro = queue.poll();
				
			result += Dectime;
			
			if((pro.time = pro.time - Dectime) > 0){
				queue.offer(pro);
			}else{
				result += pro.time;
				System.out.println(pro.name + " " + result);
			}
			
		}
	}
} Main public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String[] t = scan.nextLine().split("\\s");
		int num = Integer.parseInt(t[0]);
		int Dectime = Integer.parseInt(t[1]);
		
		Queue<Process> queue = new ArrayDeque<Process>();
		for(int i = 0; i < num; i++){
			String[] str = scan.nextLine().split("\\s");
			
			Process pro = new Process(str[0], Integer.parseInt(str[1]));
			queue.offer(pro);
		}
		
		int result = 0;
		
		while(queue.size() > 0){
			Process pro = queue.poll();
				
			result += Dectime;
			
			if((pro.time = pro.time - Dectime) > 0){
				queue.offer(pro);
			}else{
				result += pro.time;
				System.out.println(pro.name + " " + result);
			}
			
		}
	} main {
		Scanner scan = new Scanner(System.in);
		String[] t = scan.nextLine().split("\\s");
		int num = Integer.parseInt(t[0]);
		int Dectime = Integer.parseInt(t[1]);
		
		Queue<Process> queue = new ArrayDeque<Process>();
		for(int i = 0; i < num; i++){
			String[] str = scan.nextLine().split("\\s");
			
			Process pro = new Process(str[0], Integer.parseInt(str[1]));
			queue.offer(pro);
		}
		
		int result = 0;
		
		while(queue.size() > 0){
			Process pro = queue.poll();
				
			result += Dectime;
			
			if((pro.time = pro.time - Dectime) > 0){
				queue.offer(pro);
			}else{
				result += pro.time;
				System.out.println(pro.name + " " + result);
			}
			
		}
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String[] t = scan.nextLine().split("\\s"); t scan.nextLine().split("\\s") scan.nextLine().split scan.nextLine() scan.nextLine scan "\\s" int num = Integer.parseInt(t[0]); num Integer.parseInt(t[0]) Integer.parseInt Integer t[0] t 0 int Dectime = Integer.parseInt(t[1]); Dectime Integer.parseInt(t[1]) Integer.parseInt Integer t[1] t 1 Queue<Process> queue = new ArrayDeque<Process>(); queue new ArrayDeque<Process>() for(int i = 0; i < num; i++){
			String[] str = scan.nextLine().split("\\s");
			
			Process pro = new Process(str[0], Integer.parseInt(str[1]));
			queue.offer(pro);
		} int i = 0; int i = 0; i 0 i < num i num i++ i++ i {
			String[] str = scan.nextLine().split("\\s");
			
			Process pro = new Process(str[0], Integer.parseInt(str[1]));
			queue.offer(pro);
		} {
			String[] str = scan.nextLine().split("\\s");
			
			Process pro = new Process(str[0], Integer.parseInt(str[1]));
			queue.offer(pro);
		} String[] str = scan.nextLine().split("\\s"); str scan.nextLine().split("\\s") scan.nextLine().split scan.nextLine() scan.nextLine scan "\\s" Process pro = new Process(str[0], Integer.parseInt(str[1])); pro new Process(str[0], Integer.parseInt(str[1])) queue.offer(pro) queue.offer queue pro int result = 0; result 0 while(queue.size() > 0){
			Process pro = queue.poll();
				
			result += Dectime;
			
			if((pro.time = pro.time - Dectime) > 0){
				queue.offer(pro);
			}else{
				result += pro.time;
				System.out.println(pro.name + " " + result);
			}
			
		} queue.size() > 0 queue.size() queue.size queue 0 {
			Process pro = queue.poll();
				
			result += Dectime;
			
			if((pro.time = pro.time - Dectime) > 0){
				queue.offer(pro);
			}else{
				result += pro.time;
				System.out.println(pro.name + " " + result);
			}
			
		} Process pro = queue.poll(); pro queue.poll() queue.poll queue result += Dectime result Dectime if((pro.time = pro.time - Dectime) > 0){
				queue.offer(pro);
			}else{
				result += pro.time;
				System.out.println(pro.name + " " + result);
			} (pro.time = pro.time - Dectime) > 0 (pro.time = pro.time - Dectime) pro.time pro pro.time pro.time - Dectime pro.time pro pro.time Dectime 0 {
				queue.offer(pro);
			} queue.offer(pro) queue.offer queue pro {
				result += pro.time;
				System.out.println(pro.name + " " + result);
			} result += pro.time result pro.time pro pro.time System.out.println(pro.name + " " + result) System.out.println System.out System System.out pro.name + " " + result pro.name + " " + result pro.name pro pro.name " " result String[] args args class Process{
	String name = null;
	int time = 0;
	
	Process(String n, int t){
		this.name = n;
		this.time = t;
	}
} Process String name = null; name null int time = 0; time 0 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
import java.util.Scanner;
import java.util.ArrayDeque;
import java.util.Queue;
class Main {
    public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String[] t = scan.nextLine().split("\\s");
		int num = Integer.parseInt(t[0]);
		int Dectime = Integer.parseInt(t[1]);
		
		Queue<Process> queue = new ArrayDeque<Process>();
		for(int i = 0; i < num; i++){
			String[] str = scan.nextLine().split("\\s");
			
			Process pro = new Process(str[0], Integer.parseInt(str[1]));
			queue.offer(pro);
		}
		
		int result = 0;
		
		while(queue.size() > 0){
			Process pro = queue.poll();
				
			result += Dectime;
			
			if((pro.time = pro.time - Dectime) > 0){
				queue.offer(pro);
			}else{
				result += pro.time;
				System.out.println(pro.name + " " + result);
			}
			
		}
	}
}

class Process{
	String name = null;
	int time = 0;
	
	Process(String n, int t){
		this.name = n;
		this.time = t;
	}
}