import java.util.*;
class Process{
    public String name;
    public int time;
    public String getName(){
	return this.name;
    }
    public int getTime(){
	return this.time;
    }
}
class Main{

    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt(),q = sc.nextInt();
	int ttltime = 0;
	
        ArrayList<Process> p = new ArrayList<Process>();
	
	for(int i = 0;i < n;i++){
	    Process ptmp = new Process();
	    ptmp.name = sc.next();
	    ptmp.time = sc.nextInt();
	    p.add(ptmp);
	}
	
	while(p.size() > 0){
	    int T = p.get(0).getTime();
	    Process ptmp2 = new Process();
	    ptmp2.name = p.get(0).getName();
	    if(T > q){
		p.remove(0);
		ptmp2.time = T - q;
		p.add(ptmp2);
		ttltime += q;
	    }
	    else{
		ttltime += T;
		System.out.println(p.get(0).getName()+" "+ttltime);
		p.remove(0);
	    }    
	}
       
    }

} import java.util.*; util.* java class Process{
    public String name;
    public int time;
    public String getName(){
	return this.name;
    }
    public int getTime(){
	return this.time;
    }
} Process public String name; name public 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 class Main{

    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt(),q = sc.nextInt();
	int ttltime = 0;
	
        ArrayList<Process> p = new ArrayList<Process>();
	
	for(int i = 0;i < n;i++){
	    Process ptmp = new Process();
	    ptmp.name = sc.next();
	    ptmp.time = sc.nextInt();
	    p.add(ptmp);
	}
	
	while(p.size() > 0){
	    int T = p.get(0).getTime();
	    Process ptmp2 = new Process();
	    ptmp2.name = p.get(0).getName();
	    if(T > q){
		p.remove(0);
		ptmp2.time = T - q;
		p.add(ptmp2);
		ttltime += q;
	    }
	    else{
		ttltime += T;
		System.out.println(p.get(0).getName()+" "+ttltime);
		p.remove(0);
	    }    
	}
       
    }

} Main public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt(),q = sc.nextInt();
	int ttltime = 0;
	
        ArrayList<Process> p = new ArrayList<Process>();
	
	for(int i = 0;i < n;i++){
	    Process ptmp = new Process();
	    ptmp.name = sc.next();
	    ptmp.time = sc.nextInt();
	    p.add(ptmp);
	}
	
	while(p.size() > 0){
	    int T = p.get(0).getTime();
	    Process ptmp2 = new Process();
	    ptmp2.name = p.get(0).getName();
	    if(T > q){
		p.remove(0);
		ptmp2.time = T - q;
		p.add(ptmp2);
		ttltime += q;
	    }
	    else{
		ttltime += T;
		System.out.println(p.get(0).getName()+" "+ttltime);
		p.remove(0);
	    }    
	}
       
    } main {
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt(),q = sc.nextInt();
	int ttltime = 0;
	
        ArrayList<Process> p = new ArrayList<Process>();
	
	for(int i = 0;i < n;i++){
	    Process ptmp = new Process();
	    ptmp.name = sc.next();
	    ptmp.time = sc.nextInt();
	    p.add(ptmp);
	}
	
	while(p.size() > 0){
	    int T = p.get(0).getTime();
	    Process ptmp2 = new Process();
	    ptmp2.name = p.get(0).getName();
	    if(T > q){
		p.remove(0);
		ptmp2.time = T - q;
		p.add(ptmp2);
		ttltime += q;
	    }
	    else{
		ttltime += T;
		System.out.println(p.get(0).getName()+" "+ttltime);
		p.remove(0);
	    }    
	}
       
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt() n sc.nextInt() sc.nextInt sc q = sc.nextInt(); q sc.nextInt() sc.nextInt sc int ttltime = 0; ttltime 0 ArrayList<Process> p = new ArrayList<Process>(); p new ArrayList<Process>() for(int i = 0;i < n;i++){
	    Process ptmp = new Process();
	    ptmp.name = sc.next();
	    ptmp.time = sc.nextInt();
	    p.add(ptmp);
	} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
	    Process ptmp = new Process();
	    ptmp.name = sc.next();
	    ptmp.time = sc.nextInt();
	    p.add(ptmp);
	} {
	    Process ptmp = new Process();
	    ptmp.name = sc.next();
	    ptmp.time = sc.nextInt();
	    p.add(ptmp);
	} Process ptmp = new Process(); ptmp new Process() ptmp.name = sc.next() ptmp.name ptmp ptmp.name sc.next() sc.next sc ptmp.time = sc.nextInt() ptmp.time ptmp ptmp.time sc.nextInt() sc.nextInt sc p.add(ptmp) p.add p ptmp while(p.size() > 0){
	    int T = p.get(0).getTime();
	    Process ptmp2 = new Process();
	    ptmp2.name = p.get(0).getName();
	    if(T > q){
		p.remove(0);
		ptmp2.time = T - q;
		p.add(ptmp2);
		ttltime += q;
	    }
	    else{
		ttltime += T;
		System.out.println(p.get(0).getName()+" "+ttltime);
		p.remove(0);
	    }    
	} p.size() > 0 p.size() p.size p 0 {
	    int T = p.get(0).getTime();
	    Process ptmp2 = new Process();
	    ptmp2.name = p.get(0).getName();
	    if(T > q){
		p.remove(0);
		ptmp2.time = T - q;
		p.add(ptmp2);
		ttltime += q;
	    }
	    else{
		ttltime += T;
		System.out.println(p.get(0).getName()+" "+ttltime);
		p.remove(0);
	    }    
	} int T = p.get(0).getTime(); T p.get(0).getTime() p.get(0).getTime p.get(0) p.get p 0 Process ptmp2 = new Process(); ptmp2 new Process() ptmp2.name = p.get(0).getName() ptmp2.name ptmp2 ptmp2.name p.get(0).getName() p.get(0).getName p.get(0) p.get p 0 if(T > q){
		p.remove(0);
		ptmp2.time = T - q;
		p.add(ptmp2);
		ttltime += q;
	    }
	    else{
		ttltime += T;
		System.out.println(p.get(0).getName()+" "+ttltime);
		p.remove(0);
	    } T > q T q {
		p.remove(0);
		ptmp2.time = T - q;
		p.add(ptmp2);
		ttltime += q;
	    } p.remove(0) p.remove p 0 ptmp2.time = T - q ptmp2.time ptmp2 ptmp2.time T - q T q p.add(ptmp2) p.add p ptmp2 ttltime += q ttltime q {
		ttltime += T;
		System.out.println(p.get(0).getName()+" "+ttltime);
		p.remove(0);
	    } ttltime += T ttltime T System.out.println(p.get(0).getName()+" "+ttltime) System.out.println System.out System System.out p.get(0).getName()+" "+ttltime p.get(0).getName()+" "+ttltime p.get(0).getName() p.get(0).getName p.get(0) p.get p 0 " " ttltime p.remove(0) p.remove p 0 String[] args args
import java.util.*;
class Process{
    public String name;
    public int time;
    public String getName(){
	return this.name;
    }
    public int getTime(){
	return this.time;
    }
}
class Main{

    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt(),q = sc.nextInt();
	int ttltime = 0;
	
        ArrayList<Process> p = new ArrayList<Process>();
	
	for(int i = 0;i < n;i++){
	    Process ptmp = new Process();
	    ptmp.name = sc.next();
	    ptmp.time = sc.nextInt();
	    p.add(ptmp);
	}
	
	while(p.size() > 0){
	    int T = p.get(0).getTime();
	    Process ptmp2 = new Process();
	    ptmp2.name = p.get(0).getName();
	    if(T > q){
		p.remove(0);
		ptmp2.time = T - q;
		p.add(ptmp2);
		ttltime += q;
	    }
	    else{
		ttltime += T;
		System.out.println(p.get(0).getName()+" "+ttltime);
		p.remove(0);
	    }    
	}
       
    }

}
