import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.Queue;

public class Main {
  private final static class Process {
    public String name = null;
    public int pt = 0;

    public Process(String name, int pt) {
        this.name = name;
        this.pt = pt;
    }
}
    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] fr = br.readLine().split("\\s");
        int elm = Integer.parseInt(fr[0]);
        int qat = Integer.parseInt(fr[1]);
        Queue<Process> que = new LinkedList<Process>();
        for (int i = 0; i < elm; i++) {
            String[] str = br.readLine().split("\\s");
            Process process = new Process(str[0],
                    Integer.parseInt(str[1]));
            que.offer(process);
        }
        int rt = 0;
        while (que.size() > 0) {
            Process process = que.poll();
            rt += qat;
            if ((process.pt = process.pt - qat) > 0) {
                que.offer(process);
                continue; 
            }
            rt += process.pt;
            System.out.println(process.name + " " + rt);
        }

    }
    
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.LinkedList; LinkedList java.util import java.util.Queue; Queue java.util public class Main {
  private final static class Process {
    public String name = null;
    public int pt = 0;

    public Process(String name, int pt) {
        this.name = name;
        this.pt = pt;
    }
}
    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] fr = br.readLine().split("\\s");
        int elm = Integer.parseInt(fr[0]);
        int qat = Integer.parseInt(fr[1]);
        Queue<Process> que = new LinkedList<Process>();
        for (int i = 0; i < elm; i++) {
            String[] str = br.readLine().split("\\s");
            Process process = new Process(str[0],
                    Integer.parseInt(str[1]));
            que.offer(process);
        }
        int rt = 0;
        while (que.size() > 0) {
            Process process = que.poll();
            rt += qat;
            if ((process.pt = process.pt - qat) > 0) {
                que.offer(process);
                continue; 
            }
            rt += process.pt;
            System.out.println(process.name + " " + rt);
        }

    }
    
} Main public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] fr = br.readLine().split("\\s");
        int elm = Integer.parseInt(fr[0]);
        int qat = Integer.parseInt(fr[1]);
        Queue<Process> que = new LinkedList<Process>();
        for (int i = 0; i < elm; i++) {
            String[] str = br.readLine().split("\\s");
            Process process = new Process(str[0],
                    Integer.parseInt(str[1]));
            que.offer(process);
        }
        int rt = 0;
        while (que.size() > 0) {
            Process process = que.poll();
            rt += qat;
            if ((process.pt = process.pt - qat) > 0) {
                que.offer(process);
                continue; 
            }
            rt += process.pt;
            System.out.println(process.name + " " + rt);
        }

    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] fr = br.readLine().split("\\s");
        int elm = Integer.parseInt(fr[0]);
        int qat = Integer.parseInt(fr[1]);
        Queue<Process> que = new LinkedList<Process>();
        for (int i = 0; i < elm; i++) {
            String[] str = br.readLine().split("\\s");
            Process process = new Process(str[0],
                    Integer.parseInt(str[1]));
            que.offer(process);
        }
        int rt = 0;
        while (que.size() > 0) {
            Process process = que.poll();
            rt += qat;
            if ((process.pt = process.pt - qat) > 0) {
                que.offer(process);
                continue; 
            }
            rt += process.pt;
            System.out.println(process.name + " " + rt);
        }

    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] fr = br.readLine().split("\\s"); fr br.readLine().split("\\s") br.readLine().split br.readLine() br.readLine br "\\s" int elm = Integer.parseInt(fr[0]); elm Integer.parseInt(fr[0]) Integer.parseInt Integer fr[0] fr 0 int qat = Integer.parseInt(fr[1]); qat Integer.parseInt(fr[1]) Integer.parseInt Integer fr[1] fr 1 Queue<Process> que = new LinkedList<Process>(); que new LinkedList<Process>() for (int i = 0; i < elm; i++) {
            String[] str = br.readLine().split("\\s");
            Process process = new Process(str[0],
                    Integer.parseInt(str[1]));
            que.offer(process);
        } int i = 0; int i = 0; i 0 i < elm i elm i++ i++ i {
            String[] str = br.readLine().split("\\s");
            Process process = new Process(str[0],
                    Integer.parseInt(str[1]));
            que.offer(process);
        } {
            String[] str = br.readLine().split("\\s");
            Process process = new Process(str[0],
                    Integer.parseInt(str[1]));
            que.offer(process);
        } String[] str = br.readLine().split("\\s"); str br.readLine().split("\\s") br.readLine().split br.readLine() br.readLine br "\\s" Process process = new Process(str[0],
                    Integer.parseInt(str[1])); process new Process(str[0],
                    Integer.parseInt(str[1])) que.offer(process) que.offer que process int rt = 0; rt 0 while (que.size() > 0) {
            Process process = que.poll();
            rt += qat;
            if ((process.pt = process.pt - qat) > 0) {
                que.offer(process);
                continue; 
            }
            rt += process.pt;
            System.out.println(process.name + " " + rt);
        } que.size() > 0 que.size() que.size que 0 {
            Process process = que.poll();
            rt += qat;
            if ((process.pt = process.pt - qat) > 0) {
                que.offer(process);
                continue; 
            }
            rt += process.pt;
            System.out.println(process.name + " " + rt);
        } Process process = que.poll(); process que.poll() que.poll que rt += qat rt qat if ((process.pt = process.pt - qat) > 0) {
                que.offer(process);
                continue; 
            } (process.pt = process.pt - qat) > 0 (process.pt = process.pt - qat) process.pt process process.pt process.pt - qat process.pt process process.pt qat 0 {
                que.offer(process);
                continue; 
            } que.offer(process) que.offer que process continue; rt += process.pt rt process.pt process process.pt System.out.println(process.name + " " + rt) System.out.println System.out System System.out process.name + " " + rt process.name + " " + rt process.name process process.name " " rt String args[] args private final static class Process {
    public String name = null;
    public int pt = 0;

    public Process(String name, int pt) {
        this.name = name;
        this.pt = pt;
    }
} Process public String name = null; name null public int pt = 0; pt 0 public Process(String name, int pt) {
        this.name = name;
        this.pt = pt;
    } Process {
        this.name = name;
        this.pt = pt;
    } this.name = name this.name this this.name name this.pt = pt this.pt this this.pt pt String name name int pt pt public class Main {
  private final static class Process {
    public String name = null;
    public int pt = 0;

    public Process(String name, int pt) {
        this.name = name;
        this.pt = pt;
    }
}
    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] fr = br.readLine().split("\\s");
        int elm = Integer.parseInt(fr[0]);
        int qat = Integer.parseInt(fr[1]);
        Queue<Process> que = new LinkedList<Process>();
        for (int i = 0; i < elm; i++) {
            String[] str = br.readLine().split("\\s");
            Process process = new Process(str[0],
                    Integer.parseInt(str[1]));
            que.offer(process);
        }
        int rt = 0;
        while (que.size() > 0) {
            Process process = que.poll();
            rt += qat;
            if ((process.pt = process.pt - qat) > 0) {
                que.offer(process);
                continue; 
            }
            rt += process.pt;
            System.out.println(process.name + " " + rt);
        }

    }
    
} public class Main {
  private final static class Process {
    public String name = null;
    public int pt = 0;

    public Process(String name, int pt) {
        this.name = name;
        this.pt = pt;
    }
}
    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] fr = br.readLine().split("\\s");
        int elm = Integer.parseInt(fr[0]);
        int qat = Integer.parseInt(fr[1]);
        Queue<Process> que = new LinkedList<Process>();
        for (int i = 0; i < elm; i++) {
            String[] str = br.readLine().split("\\s");
            Process process = new Process(str[0],
                    Integer.parseInt(str[1]));
            que.offer(process);
        }
        int rt = 0;
        while (que.size() > 0) {
            Process process = que.poll();
            rt += qat;
            if ((process.pt = process.pt - qat) > 0) {
                que.offer(process);
                continue; 
            }
            rt += process.pt;
            System.out.println(process.name + " " + rt);
        }

    }
    
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.Queue;

public class Main {
  private final static class Process {
    public String name = null;
    public int pt = 0;

    public Process(String name, int pt) {
        this.name = name;
        this.pt = pt;
    }
}
    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] fr = br.readLine().split("\\s");
        int elm = Integer.parseInt(fr[0]);
        int qat = Integer.parseInt(fr[1]);
        Queue<Process> que = new LinkedList<Process>();
        for (int i = 0; i < elm; i++) {
            String[] str = br.readLine().split("\\s");
            Process process = new Process(str[0],
                    Integer.parseInt(str[1]));
            que.offer(process);
        }
        int rt = 0;
        while (que.size() > 0) {
            Process process = que.poll();
            rt += qat;
            if ((process.pt = process.pt - qat) > 0) {
                que.offer(process);
                continue; 
            }
            rt += process.pt;
            System.out.println(process.name + " " + rt);
        }

    }
    
}
