import java.util.*;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n,t;
        int nowt=0;
        ArrayList<P> list = new ArrayList<P>();
        n = sc.nextInt();
        t = sc.nextInt();
        sc.nextLine();
        for(int i=0;i<n;i++){
            String str[] = sc.nextLine().split(" ");
            list.add(new P(str[0],Integer.parseInt(str[1])));
        }
        while(list.size()!=0){
            P p = list.get(0);
            list.remove(0);
            if(p.t<=t){
                nowt+=p.t;
                System.out.println(p.name+" "+nowt);
            }else{
                p.t-=t;
                nowt+=t;
                list.add(p);
            }
        }
    }
}

class P{
    String name;
    int t;
    public P(String s,int tt){
        name = s;
        t = tt;
    }
} import java.util.*; util.* java class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n,t;
        int nowt=0;
        ArrayList<P> list = new ArrayList<P>();
        n = sc.nextInt();
        t = sc.nextInt();
        sc.nextLine();
        for(int i=0;i<n;i++){
            String str[] = sc.nextLine().split(" ");
            list.add(new P(str[0],Integer.parseInt(str[1])));
        }
        while(list.size()!=0){
            P p = list.get(0);
            list.remove(0);
            if(p.t<=t){
                nowt+=p.t;
                System.out.println(p.name+" "+nowt);
            }else{
                p.t-=t;
                nowt+=t;
                list.add(p);
            }
        }
    }
} Main public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n,t;
        int nowt=0;
        ArrayList<P> list = new ArrayList<P>();
        n = sc.nextInt();
        t = sc.nextInt();
        sc.nextLine();
        for(int i=0;i<n;i++){
            String str[] = sc.nextLine().split(" ");
            list.add(new P(str[0],Integer.parseInt(str[1])));
        }
        while(list.size()!=0){
            P p = list.get(0);
            list.remove(0);
            if(p.t<=t){
                nowt+=p.t;
                System.out.println(p.name+" "+nowt);
            }else{
                p.t-=t;
                nowt+=t;
                list.add(p);
            }
        }
    } main {
        Scanner sc = new Scanner(System.in);
        int n,t;
        int nowt=0;
        ArrayList<P> list = new ArrayList<P>();
        n = sc.nextInt();
        t = sc.nextInt();
        sc.nextLine();
        for(int i=0;i<n;i++){
            String str[] = sc.nextLine().split(" ");
            list.add(new P(str[0],Integer.parseInt(str[1])));
        }
        while(list.size()!=0){
            P p = list.get(0);
            list.remove(0);
            if(p.t<=t){
                nowt+=p.t;
                System.out.println(p.name+" "+nowt);
            }else{
                p.t-=t;
                nowt+=t;
                list.add(p);
            }
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n n t; t int nowt=0; nowt 0 ArrayList<P> list = new ArrayList<P>(); list new ArrayList<P>() n = sc.nextInt() n sc.nextInt() sc.nextInt sc t = sc.nextInt() t sc.nextInt() sc.nextInt sc sc.nextLine() sc.nextLine sc for(int i=0;i<n;i++){
            String str[] = sc.nextLine().split(" ");
            list.add(new P(str[0],Integer.parseInt(str[1])));
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            String str[] = sc.nextLine().split(" ");
            list.add(new P(str[0],Integer.parseInt(str[1])));
        } {
            String str[] = sc.nextLine().split(" ");
            list.add(new P(str[0],Integer.parseInt(str[1])));
        } String str[] = sc.nextLine().split(" "); str sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " list.add(new P(str[0],Integer.parseInt(str[1]))) list.add list new P(str[0],Integer.parseInt(str[1])) while(list.size()!=0){
            P p = list.get(0);
            list.remove(0);
            if(p.t<=t){
                nowt+=p.t;
                System.out.println(p.name+" "+nowt);
            }else{
                p.t-=t;
                nowt+=t;
                list.add(p);
            }
        } list.size()!=0 list.size() list.size list 0 {
            P p = list.get(0);
            list.remove(0);
            if(p.t<=t){
                nowt+=p.t;
                System.out.println(p.name+" "+nowt);
            }else{
                p.t-=t;
                nowt+=t;
                list.add(p);
            }
        } P p = list.get(0); p list.get(0) list.get list 0 list.remove(0) list.remove list 0 if(p.t<=t){
                nowt+=p.t;
                System.out.println(p.name+" "+nowt);
            }else{
                p.t-=t;
                nowt+=t;
                list.add(p);
            } p.t<=t p.t p p.t t {
                nowt+=p.t;
                System.out.println(p.name+" "+nowt);
            } nowt+=p.t nowt p.t p p.t System.out.println(p.name+" "+nowt) System.out.println System.out System System.out p.name+" "+nowt p.name+" "+nowt p.name p p.name " " nowt {
                p.t-=t;
                nowt+=t;
                list.add(p);
            } p.t-=t p.t p p.t t nowt+=t nowt t list.add(p) list.add list p String args[] args class P{
    String name;
    int t;
    public P(String s,int tt){
        name = s;
        t = tt;
    }
} P String name; name int t; t public P(String s,int tt){
        name = s;
        t = tt;
    } P {
        name = s;
        t = tt;
    } name = s name s t = tt t tt String s s int tt tt
import java.util.*;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n,t;
        int nowt=0;
        ArrayList<P> list = new ArrayList<P>();
        n = sc.nextInt();
        t = sc.nextInt();
        sc.nextLine();
        for(int i=0;i<n;i++){
            String str[] = sc.nextLine().split(" ");
            list.add(new P(str[0],Integer.parseInt(str[1])));
        }
        while(list.size()!=0){
            P p = list.get(0);
            list.remove(0);
            if(p.t<=t){
                nowt+=p.t;
                System.out.println(p.name+" "+nowt);
            }else{
                p.t-=t;
                nowt+=t;
                list.add(p);
            }
        }
    }
}

class P{
    String name;
    int t;
    public P(String s,int tt){
        name = s;
        t = tt;
    }
}
