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

public class Main {

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

		int n = Integer.parseInt(tmp[0]);
		int qTime = Integer.parseInt(tmp[1]);

		Process[] pAry = new Process[n+1];

		for(int i = 0 ; i < n ; i++){
			tmp =  br.readLine().split(" ");
			pAry[i] = new Process(tmp[0],Integer.parseInt(tmp[1]));
		}

		boolean isFinished = false;
		int top = 0;
		int tail = n;
		int cureentTime = 0;

		while(!isFinished){

			if(pAry[top].time - qTime <= 0){
				cureentTime += pAry[top].time;
				System.out.println(pAry[top].name + " " + cureentTime );
			}else{
				pAry[top].time -= qTime;
				pAry[tail] = pAry[top];
				tail = (tail + 1) % (n + 1);
				cureentTime += qTime;
			}
			top = (top + 1) % (n + 1);
			if(top == tail){
				isFinished = true;
			}
		}
	}
}

class Process {

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

	public String name;
	public int time;
} 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 void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] tmp =  br.readLine().split(" ");

		int n = Integer.parseInt(tmp[0]);
		int qTime = Integer.parseInt(tmp[1]);

		Process[] pAry = new Process[n+1];

		for(int i = 0 ; i < n ; i++){
			tmp =  br.readLine().split(" ");
			pAry[i] = new Process(tmp[0],Integer.parseInt(tmp[1]));
		}

		boolean isFinished = false;
		int top = 0;
		int tail = n;
		int cureentTime = 0;

		while(!isFinished){

			if(pAry[top].time - qTime <= 0){
				cureentTime += pAry[top].time;
				System.out.println(pAry[top].name + " " + cureentTime );
			}else{
				pAry[top].time -= qTime;
				pAry[tail] = pAry[top];
				tail = (tail + 1) % (n + 1);
				cureentTime += qTime;
			}
			top = (top + 1) % (n + 1);
			if(top == tail){
				isFinished = true;
			}
		}
	}
} Main public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] tmp =  br.readLine().split(" ");

		int n = Integer.parseInt(tmp[0]);
		int qTime = Integer.parseInt(tmp[1]);

		Process[] pAry = new Process[n+1];

		for(int i = 0 ; i < n ; i++){
			tmp =  br.readLine().split(" ");
			pAry[i] = new Process(tmp[0],Integer.parseInt(tmp[1]));
		}

		boolean isFinished = false;
		int top = 0;
		int tail = n;
		int cureentTime = 0;

		while(!isFinished){

			if(pAry[top].time - qTime <= 0){
				cureentTime += pAry[top].time;
				System.out.println(pAry[top].name + " " + cureentTime );
			}else{
				pAry[top].time -= qTime;
				pAry[tail] = pAry[top];
				tail = (tail + 1) % (n + 1);
				cureentTime += qTime;
			}
			top = (top + 1) % (n + 1);
			if(top == tail){
				isFinished = true;
			}
		}
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] tmp =  br.readLine().split(" ");

		int n = Integer.parseInt(tmp[0]);
		int qTime = Integer.parseInt(tmp[1]);

		Process[] pAry = new Process[n+1];

		for(int i = 0 ; i < n ; i++){
			tmp =  br.readLine().split(" ");
			pAry[i] = new Process(tmp[0],Integer.parseInt(tmp[1]));
		}

		boolean isFinished = false;
		int top = 0;
		int tail = n;
		int cureentTime = 0;

		while(!isFinished){

			if(pAry[top].time - qTime <= 0){
				cureentTime += pAry[top].time;
				System.out.println(pAry[top].name + " " + cureentTime );
			}else{
				pAry[top].time -= qTime;
				pAry[tail] = pAry[top];
				tail = (tail + 1) % (n + 1);
				cureentTime += qTime;
			}
			top = (top + 1) % (n + 1);
			if(top == tail){
				isFinished = true;
			}
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] tmp =  br.readLine().split(" "); tmp br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int n = Integer.parseInt(tmp[0]); n Integer.parseInt(tmp[0]) Integer.parseInt Integer tmp[0] tmp 0 int qTime = Integer.parseInt(tmp[1]); qTime Integer.parseInt(tmp[1]) Integer.parseInt Integer tmp[1] tmp 1 Process[] pAry = new Process[n+1]; pAry new Process[n+1] n+1 n 1 for(int i = 0 ; i < n ; i++){
			tmp =  br.readLine().split(" ");
			pAry[i] = new Process(tmp[0],Integer.parseInt(tmp[1]));
		} int i = 0 ; int i = 0 ; i 0 i < n i n i++ i++ i {
			tmp =  br.readLine().split(" ");
			pAry[i] = new Process(tmp[0],Integer.parseInt(tmp[1]));
		} {
			tmp =  br.readLine().split(" ");
			pAry[i] = new Process(tmp[0],Integer.parseInt(tmp[1]));
		} tmp =  br.readLine().split(" ") tmp br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " pAry[i] = new Process(tmp[0],Integer.parseInt(tmp[1])) pAry[i] pAry i new Process(tmp[0],Integer.parseInt(tmp[1])) boolean isFinished = false; isFinished false int top = 0; top 0 int tail = n; tail n int cureentTime = 0; cureentTime 0 while(!isFinished){

			if(pAry[top].time - qTime <= 0){
				cureentTime += pAry[top].time;
				System.out.println(pAry[top].name + " " + cureentTime );
			}else{
				pAry[top].time -= qTime;
				pAry[tail] = pAry[top];
				tail = (tail + 1) % (n + 1);
				cureentTime += qTime;
			}
			top = (top + 1) % (n + 1);
			if(top == tail){
				isFinished = true;
			}
		} !isFinished isFinished {

			if(pAry[top].time - qTime <= 0){
				cureentTime += pAry[top].time;
				System.out.println(pAry[top].name + " " + cureentTime );
			}else{
				pAry[top].time -= qTime;
				pAry[tail] = pAry[top];
				tail = (tail + 1) % (n + 1);
				cureentTime += qTime;
			}
			top = (top + 1) % (n + 1);
			if(top == tail){
				isFinished = true;
			}
		} if(pAry[top].time - qTime <= 0){
				cureentTime += pAry[top].time;
				System.out.println(pAry[top].name + " " + cureentTime );
			}else{
				pAry[top].time -= qTime;
				pAry[tail] = pAry[top];
				tail = (tail + 1) % (n + 1);
				cureentTime += qTime;
			} pAry[top].time - qTime <= 0 pAry[top].time - qTime pAry[top].time pAry[top] pAry top pAry[top].time qTime 0 {
				cureentTime += pAry[top].time;
				System.out.println(pAry[top].name + " " + cureentTime );
			} cureentTime += pAry[top].time cureentTime pAry[top].time pAry[top] pAry top pAry[top].time System.out.println(pAry[top].name + " " + cureentTime ) System.out.println System.out System System.out pAry[top].name + " " + cureentTime pAry[top].name + " " + cureentTime pAry[top].name pAry[top] pAry top pAry[top].name " " cureentTime {
				pAry[top].time -= qTime;
				pAry[tail] = pAry[top];
				tail = (tail + 1) % (n + 1);
				cureentTime += qTime;
			} pAry[top].time -= qTime pAry[top].time pAry[top] pAry top pAry[top].time qTime pAry[tail] = pAry[top] pAry[tail] pAry tail pAry[top] pAry top tail = (tail + 1) % (n + 1) tail (tail + 1) % (n + 1) (tail + 1) tail 1 (n + 1) n 1 cureentTime += qTime cureentTime qTime top = (top + 1) % (n + 1) top (top + 1) % (n + 1) (top + 1) top 1 (n + 1) n 1 if(top == tail){
				isFinished = true;
			} top == tail top tail {
				isFinished = true;
			} isFinished = true isFinished true String[] args args class Process {

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

	public String name;
	public int time;
} Process public String name; name public 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 class Main {

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

		int n = Integer.parseInt(tmp[0]);
		int qTime = Integer.parseInt(tmp[1]);

		Process[] pAry = new Process[n+1];

		for(int i = 0 ; i < n ; i++){
			tmp =  br.readLine().split(" ");
			pAry[i] = new Process(tmp[0],Integer.parseInt(tmp[1]));
		}

		boolean isFinished = false;
		int top = 0;
		int tail = n;
		int cureentTime = 0;

		while(!isFinished){

			if(pAry[top].time - qTime <= 0){
				cureentTime += pAry[top].time;
				System.out.println(pAry[top].name + " " + cureentTime );
			}else{
				pAry[top].time -= qTime;
				pAry[tail] = pAry[top];
				tail = (tail + 1) % (n + 1);
				cureentTime += qTime;
			}
			top = (top + 1) % (n + 1);
			if(top == tail){
				isFinished = true;
			}
		}
	}
} public class Main {

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

		int n = Integer.parseInt(tmp[0]);
		int qTime = Integer.parseInt(tmp[1]);

		Process[] pAry = new Process[n+1];

		for(int i = 0 ; i < n ; i++){
			tmp =  br.readLine().split(" ");
			pAry[i] = new Process(tmp[0],Integer.parseInt(tmp[1]));
		}

		boolean isFinished = false;
		int top = 0;
		int tail = n;
		int cureentTime = 0;

		while(!isFinished){

			if(pAry[top].time - qTime <= 0){
				cureentTime += pAry[top].time;
				System.out.println(pAry[top].name + " " + cureentTime );
			}else{
				pAry[top].time -= qTime;
				pAry[tail] = pAry[top];
				tail = (tail + 1) % (n + 1);
				cureentTime += qTime;
			}
			top = (top + 1) % (n + 1);
			if(top == tail){
				isFinished = true;
			}
		}
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

		int n = Integer.parseInt(tmp[0]);
		int qTime = Integer.parseInt(tmp[1]);

		Process[] pAry = new Process[n+1];

		for(int i = 0 ; i < n ; i++){
			tmp =  br.readLine().split(" ");
			pAry[i] = new Process(tmp[0],Integer.parseInt(tmp[1]));
		}

		boolean isFinished = false;
		int top = 0;
		int tail = n;
		int cureentTime = 0;

		while(!isFinished){

			if(pAry[top].time - qTime <= 0){
				cureentTime += pAry[top].time;
				System.out.println(pAry[top].name + " " + cureentTime );
			}else{
				pAry[top].time -= qTime;
				pAry[tail] = pAry[top];
				tail = (tail + 1) % (n + 1);
				cureentTime += qTime;
			}
			top = (top + 1) % (n + 1);
			if(top == tail){
				isFinished = true;
			}
		}
	}
}

class Process {

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

	public String name;
	public int time;
}