
import javax.xml.crypto.Data;
import java.util.*;
import java.io.*;

public class Main {
    public static int SENTINEL = 100000007;
    public static int MAX = 10007;
    public static int NIL = -1;

    public static int[] dp = new int[100];


    public static void main(String[] args) throws IOException {

        //??\???
        /*
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        */

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        P[] PP = new P[n];
        Queue<P> Q = new ArrayDeque<P>();

        for(int i = 0; i < n; i++) {
            PP[i] = new P(sc.next(), sc.nextInt());
            Q.offer(PP[i]);
        }

        int T = 0;
        while(!Q.isEmpty()) {
            P Process = Q.poll();
            if(Process.time <= q) {
                T += Process.time;
                System.out.print(Process.name + " " + T);
                System.out.println();
            }
            else {
                T += q;
                P newProcess = new P(Process.name, Process.time - q);
                Q.offer(newProcess);
            }
        }
    }

}

class Stack {
    int top;
    int MAX = 100007;
    int[] S = new int[MAX];

    Stack() {
        top = 0;
    }
    boolean isEmpty() {
        return top == 0;
    }
    boolean isFull() {
        return top > MAX;
    }
    void push(int x) {
        if(isFull()) return;
        top++;
        S[top] = x;
    }
    int pop() {
        if(isEmpty()) return -1;
        top--;
        return S[top + 1];
    }
}


class P {
    String name;
    int time;
    P(String n, int t) {
        name = n;
        time = t;
    }
} import javax.xml.crypto.Data; Data javax.xml.crypto import java.util.*; util.* java import java.io.*; io.* java public class Main {
    public static int SENTINEL = 100000007;
    public static int MAX = 10007;
    public static int NIL = -1;

    public static int[] dp = new int[100];


    public static void main(String[] args) throws IOException {

        //??\???
        /*
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        */

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        P[] PP = new P[n];
        Queue<P> Q = new ArrayDeque<P>();

        for(int i = 0; i < n; i++) {
            PP[i] = new P(sc.next(), sc.nextInt());
            Q.offer(PP[i]);
        }

        int T = 0;
        while(!Q.isEmpty()) {
            P Process = Q.poll();
            if(Process.time <= q) {
                T += Process.time;
                System.out.print(Process.name + " " + T);
                System.out.println();
            }
            else {
                T += q;
                P newProcess = new P(Process.name, Process.time - q);
                Q.offer(newProcess);
            }
        }
    }

} Main public static int SENTINEL = 100000007; SENTINEL 100000007 public static int MAX = 10007; MAX 10007 public static int NIL = -1; NIL -1 1 public static int[] dp = new int[100]; dp new int[100] 100 public static void main(String[] args) throws IOException {

        //??\???
        /*
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        */

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        P[] PP = new P[n];
        Queue<P> Q = new ArrayDeque<P>();

        for(int i = 0; i < n; i++) {
            PP[i] = new P(sc.next(), sc.nextInt());
            Q.offer(PP[i]);
        }

        int T = 0;
        while(!Q.isEmpty()) {
            P Process = Q.poll();
            if(Process.time <= q) {
                T += Process.time;
                System.out.print(Process.name + " " + T);
                System.out.println();
            }
            else {
                T += q;
                P newProcess = new P(Process.name, Process.time - q);
                Q.offer(newProcess);
            }
        }
    } main {

        //??\???
        /*
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        */

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        P[] PP = new P[n];
        Queue<P> Q = new ArrayDeque<P>();

        for(int i = 0; i < n; i++) {
            PP[i] = new P(sc.next(), sc.nextInt());
            Q.offer(PP[i]);
        }

        int T = 0;
        while(!Q.isEmpty()) {
            P Process = Q.poll();
            if(Process.time <= q) {
                T += Process.time;
                System.out.print(Process.name + " " + T);
                System.out.println();
            }
            else {
                T += q;
                P newProcess = new P(Process.name, Process.time - q);
                Q.offer(newProcess);
            }
        }
    } 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 P[] PP = new P[n]; PP new P[n] n Queue<P> Q = new ArrayDeque<P>(); Q new ArrayDeque<P>() for(int i = 0; i < n; i++) {
            PP[i] = new P(sc.next(), sc.nextInt());
            Q.offer(PP[i]);
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            PP[i] = new P(sc.next(), sc.nextInt());
            Q.offer(PP[i]);
        } {
            PP[i] = new P(sc.next(), sc.nextInt());
            Q.offer(PP[i]);
        } PP[i] = new P(sc.next(), sc.nextInt()) PP[i] PP i new P(sc.next(), sc.nextInt()) Q.offer(PP[i]) Q.offer Q PP[i] PP i int T = 0; T 0 while(!Q.isEmpty()) {
            P Process = Q.poll();
            if(Process.time <= q) {
                T += Process.time;
                System.out.print(Process.name + " " + T);
                System.out.println();
            }
            else {
                T += q;
                P newProcess = new P(Process.name, Process.time - q);
                Q.offer(newProcess);
            }
        } !Q.isEmpty() Q.isEmpty() Q.isEmpty Q {
            P Process = Q.poll();
            if(Process.time <= q) {
                T += Process.time;
                System.out.print(Process.name + " " + T);
                System.out.println();
            }
            else {
                T += q;
                P newProcess = new P(Process.name, Process.time - q);
                Q.offer(newProcess);
            }
        } P Process = Q.poll(); Process Q.poll() Q.poll Q if(Process.time <= q) {
                T += Process.time;
                System.out.print(Process.name + " " + T);
                System.out.println();
            }
            else {
                T += q;
                P newProcess = new P(Process.name, Process.time - q);
                Q.offer(newProcess);
            } Process.time <= q Process.time Process Process.time q {
                T += Process.time;
                System.out.print(Process.name + " " + T);
                System.out.println();
            } T += Process.time T Process.time Process Process.time System.out.print(Process.name + " " + T) System.out.print System.out System System.out Process.name + " " + T Process.name + " " + T Process.name Process Process.name " " T System.out.println() System.out.println System.out System System.out {
                T += q;
                P newProcess = new P(Process.name, Process.time - q);
                Q.offer(newProcess);
            } T += q T q P newProcess = new P(Process.name, Process.time - q); newProcess new P(Process.name, Process.time - q) Q.offer(newProcess) Q.offer Q newProcess String[] args args class Stack {
    int top;
    int MAX = 100007;
    int[] S = new int[MAX];

    Stack() {
        top = 0;
    }
    boolean isEmpty() {
        return top == 0;
    }
    boolean isFull() {
        return top > MAX;
    }
    void push(int x) {
        if(isFull()) return;
        top++;
        S[top] = x;
    }
    int pop() {
        if(isEmpty()) return -1;
        top--;
        return S[top + 1];
    }
} Stack int top; top int MAX = 100007; MAX 100007 int[] S = new int[MAX]; S new int[MAX] MAX Stack() {
        top = 0;
    } Stack {
        top = 0;
    } top = 0 top 0 boolean isEmpty() {
        return top == 0;
    } isEmpty {
        return top == 0;
    } return top == 0; top == 0 top 0 boolean isFull() {
        return top > MAX;
    } isFull {
        return top > MAX;
    } return top > MAX; top > MAX top MAX void push(int x) {
        if(isFull()) return;
        top++;
        S[top] = x;
    } push {
        if(isFull()) return;
        top++;
        S[top] = x;
    } if(isFull()) return; isFull() isFull return; top++ top S[top] = x S[top] S top x int x x int pop() {
        if(isEmpty()) return -1;
        top--;
        return S[top + 1];
    } pop {
        if(isEmpty()) return -1;
        top--;
        return S[top + 1];
    } if(isEmpty()) return -1; isEmpty() isEmpty return -1; -1 1 top-- top return S[top + 1]; S[top + 1] S top + 1 top 1 class P {
    String name;
    int time;
    P(String n, int t) {
        name = n;
        time = t;
    }
} P String name; name int time; time P(String n, int t) {
        name = n;
        time = t;
    } P {
        name = n;
        time = t;
    } name = n name n time = t time t String n n int t t public class Main {
    public static int SENTINEL = 100000007;
    public static int MAX = 10007;
    public static int NIL = -1;

    public static int[] dp = new int[100];


    public static void main(String[] args) throws IOException {

        //??\???
        /*
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        */

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        P[] PP = new P[n];
        Queue<P> Q = new ArrayDeque<P>();

        for(int i = 0; i < n; i++) {
            PP[i] = new P(sc.next(), sc.nextInt());
            Q.offer(PP[i]);
        }

        int T = 0;
        while(!Q.isEmpty()) {
            P Process = Q.poll();
            if(Process.time <= q) {
                T += Process.time;
                System.out.print(Process.name + " " + T);
                System.out.println();
            }
            else {
                T += q;
                P newProcess = new P(Process.name, Process.time - q);
                Q.offer(newProcess);
            }
        }
    }

} public class Main {
    public static int SENTINEL = 100000007;
    public static int MAX = 10007;
    public static int NIL = -1;

    public static int[] dp = new int[100];


    public static void main(String[] args) throws IOException {

        //??\???
        /*
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        */

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        P[] PP = new P[n];
        Queue<P> Q = new ArrayDeque<P>();

        for(int i = 0; i < n; i++) {
            PP[i] = new P(sc.next(), sc.nextInt());
            Q.offer(PP[i]);
        }

        int T = 0;
        while(!Q.isEmpty()) {
            P Process = Q.poll();
            if(Process.time <= q) {
                T += Process.time;
                System.out.print(Process.name + " " + T);
                System.out.println();
            }
            else {
                T += q;
                P newProcess = new P(Process.name, Process.time - q);
                Q.offer(newProcess);
            }
        }
    }

} Main

import javax.xml.crypto.Data;
import java.util.*;
import java.io.*;

public class Main {
    public static int SENTINEL = 100000007;
    public static int MAX = 10007;
    public static int NIL = -1;

    public static int[] dp = new int[100];


    public static void main(String[] args) throws IOException {

        //??\???
        /*
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        */

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        P[] PP = new P[n];
        Queue<P> Q = new ArrayDeque<P>();

        for(int i = 0; i < n; i++) {
            PP[i] = new P(sc.next(), sc.nextInt());
            Q.offer(PP[i]);
        }

        int T = 0;
        while(!Q.isEmpty()) {
            P Process = Q.poll();
            if(Process.time <= q) {
                T += Process.time;
                System.out.print(Process.name + " " + T);
                System.out.println();
            }
            else {
                T += q;
                P newProcess = new P(Process.name, Process.time - q);
                Q.offer(newProcess);
            }
        }
    }

}

class Stack {
    int top;
    int MAX = 100007;
    int[] S = new int[MAX];

    Stack() {
        top = 0;
    }
    boolean isEmpty() {
        return top == 0;
    }
    boolean isFull() {
        return top > MAX;
    }
    void push(int x) {
        if(isFull()) return;
        top++;
        S[top] = x;
    }
    int pop() {
        if(isEmpty()) return -1;
        top--;
        return S[top + 1];
    }
}


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