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


class Main {
  public static void main(String[] args) {
    //input
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int q = sc.nextInt();
    Deque<MyProcess> d = new ArrayDeque<MyProcess>();
    for(int i = 0; i < n; ++i) {
    	String name = sc.next();
    	int time = sc.nextInt();
    	d.add(new MyProcess(name, time));
    }
    
    int elapsed = 0;
    while(!d.isEmpty()){
    	 MyProcess p = d.removeFirst();
    	 if(p.time > q) {
	    	elapsed += q;
	    	d.add(new MyProcess(p.name, p.time - q));
    	 }else{
    	 	elapsed += p.time;
    	 	System.out.println(p.name + " "  + elapsed);
    	 }
    }
  }
}

class MyProcess {
	public String name;
	public int time;
	public MyProcess(String n, int t) {
		name = n;
 		time = t;
 	}
 } import java.util.Scanner; Scanner java.util import java.util.ArrayDeque; ArrayDeque java.util import java.util.Deque; Deque java.util class Main {
  public static void main(String[] args) {
    //input
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int q = sc.nextInt();
    Deque<MyProcess> d = new ArrayDeque<MyProcess>();
    for(int i = 0; i < n; ++i) {
    	String name = sc.next();
    	int time = sc.nextInt();
    	d.add(new MyProcess(name, time));
    }
    
    int elapsed = 0;
    while(!d.isEmpty()){
    	 MyProcess p = d.removeFirst();
    	 if(p.time > q) {
	    	elapsed += q;
	    	d.add(new MyProcess(p.name, p.time - q));
    	 }else{
    	 	elapsed += p.time;
    	 	System.out.println(p.name + " "  + elapsed);
    	 }
    }
  }
} Main public static void main(String[] args) {
    //input
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int q = sc.nextInt();
    Deque<MyProcess> d = new ArrayDeque<MyProcess>();
    for(int i = 0; i < n; ++i) {
    	String name = sc.next();
    	int time = sc.nextInt();
    	d.add(new MyProcess(name, time));
    }
    
    int elapsed = 0;
    while(!d.isEmpty()){
    	 MyProcess p = d.removeFirst();
    	 if(p.time > q) {
	    	elapsed += q;
	    	d.add(new MyProcess(p.name, p.time - q));
    	 }else{
    	 	elapsed += p.time;
    	 	System.out.println(p.name + " "  + elapsed);
    	 }
    }
  } main {
    //input
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int q = sc.nextInt();
    Deque<MyProcess> d = new ArrayDeque<MyProcess>();
    for(int i = 0; i < n; ++i) {
    	String name = sc.next();
    	int time = sc.nextInt();
    	d.add(new MyProcess(name, time));
    }
    
    int elapsed = 0;
    while(!d.isEmpty()){
    	 MyProcess p = d.removeFirst();
    	 if(p.time > q) {
	    	elapsed += q;
	    	d.add(new MyProcess(p.name, p.time - q));
    	 }else{
    	 	elapsed += p.time;
    	 	System.out.println(p.name + " "  + elapsed);
    	 }
    }
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int q = sc.nextInt(); q sc.nextInt() sc.nextInt sc Deque<MyProcess> d = new ArrayDeque<MyProcess>(); d new ArrayDeque<MyProcess>() for(int i = 0; i < n; ++i) {
    	String name = sc.next();
    	int time = sc.nextInt();
    	d.add(new MyProcess(name, time));
    } int i = 0; int i = 0; i 0 i < n i n ++i ++i i {
    	String name = sc.next();
    	int time = sc.nextInt();
    	d.add(new MyProcess(name, time));
    } {
    	String name = sc.next();
    	int time = sc.nextInt();
    	d.add(new MyProcess(name, time));
    } String name = sc.next(); name sc.next() sc.next sc int time = sc.nextInt(); time sc.nextInt() sc.nextInt sc d.add(new MyProcess(name, time)) d.add d new MyProcess(name, time) int elapsed = 0; elapsed 0 while(!d.isEmpty()){
    	 MyProcess p = d.removeFirst();
    	 if(p.time > q) {
	    	elapsed += q;
	    	d.add(new MyProcess(p.name, p.time - q));
    	 }else{
    	 	elapsed += p.time;
    	 	System.out.println(p.name + " "  + elapsed);
    	 }
    } !d.isEmpty() d.isEmpty() d.isEmpty d {
    	 MyProcess p = d.removeFirst();
    	 if(p.time > q) {
	    	elapsed += q;
	    	d.add(new MyProcess(p.name, p.time - q));
    	 }else{
    	 	elapsed += p.time;
    	 	System.out.println(p.name + " "  + elapsed);
    	 }
    } MyProcess p = d.removeFirst(); p d.removeFirst() d.removeFirst d if(p.time > q) {
	    	elapsed += q;
	    	d.add(new MyProcess(p.name, p.time - q));
    	 }else{
    	 	elapsed += p.time;
    	 	System.out.println(p.name + " "  + elapsed);
    	 } p.time > q p.time p p.time q {
	    	elapsed += q;
	    	d.add(new MyProcess(p.name, p.time - q));
    	 } elapsed += q elapsed q d.add(new MyProcess(p.name, p.time - q)) d.add d new MyProcess(p.name, p.time - q) {
    	 	elapsed += p.time;
    	 	System.out.println(p.name + " "  + elapsed);
    	 } elapsed += p.time elapsed p.time p p.time System.out.println(p.name + " "  + elapsed) System.out.println System.out System System.out p.name + " "  + elapsed p.name + " "  + elapsed p.name p p.name " " elapsed String[] args args class MyProcess {
	public String name;
	public int time;
	public MyProcess(String n, int t) {
		name = n;
 		time = t;
 	}
 } MyProcess public String name; name public int time; time public MyProcess(String n, int t) {
		name = n;
 		time = t;
 	} MyProcess {
		name = n;
 		time = t;
 	} name = n name n time = t time t String n n int t t
import java.util.Scanner;
import java.util.ArrayDeque;
import java.util.Deque;


class Main {
  public static void main(String[] args) {
    //input
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int q = sc.nextInt();
    Deque<MyProcess> d = new ArrayDeque<MyProcess>();
    for(int i = 0; i < n; ++i) {
    	String name = sc.next();
    	int time = sc.nextInt();
    	d.add(new MyProcess(name, time));
    }
    
    int elapsed = 0;
    while(!d.isEmpty()){
    	 MyProcess p = d.removeFirst();
    	 if(p.time > q) {
	    	elapsed += q;
	    	d.add(new MyProcess(p.name, p.time - q));
    	 }else{
    	 	elapsed += p.time;
    	 	System.out.println(p.name + " "  + elapsed);
    	 }
    }
  }
}

class MyProcess {
	public String name;
	public int time;
	public MyProcess(String n, int t) {
		name = n;
 		time = t;
 	}
 }