
import java.util.*;
import java.lang.*;

class Process {
    String id;
    int time;
    Process(String x, int t) {
        id = x;
        time = t;
    }
}


public class Main {
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int qtm = sc.nextInt();
        int count = 0;
        ArrayList<Process> queue = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            queue.add(new Process(sc.next(), sc.nextInt()));
        }

        while(true) {
            if (queue.isEmpty()) {
                break;
            }
            Process element = queue.get(0);
            if (element.time > qtm) {
                element.time -= qtm;
                count += qtm;
                queue.remove(0);
                queue.add(element);
            } else {
                count += element.time;
                queue.remove(0);
                System.out.println(element.id + " " + count);
            }
        }
    }
} import java.util.*; util.* java import java.lang.*; lang.* java class Process {
    String id;
    int time;
    Process(String x, int t) {
        id = x;
        time = t;
    }
} Process String id; id int time; time Process(String x, int t) {
        id = x;
        time = t;
    } Process {
        id = x;
        time = t;
    } id = x id x time = t time t String x x int t t public class Main {
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int qtm = sc.nextInt();
        int count = 0;
        ArrayList<Process> queue = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            queue.add(new Process(sc.next(), sc.nextInt()));
        }

        while(true) {
            if (queue.isEmpty()) {
                break;
            }
            Process element = queue.get(0);
            if (element.time > qtm) {
                element.time -= qtm;
                count += qtm;
                queue.remove(0);
                queue.add(element);
            } else {
                count += element.time;
                queue.remove(0);
                System.out.println(element.id + " " + count);
            }
        }
    }
} Main public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int qtm = sc.nextInt();
        int count = 0;
        ArrayList<Process> queue = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            queue.add(new Process(sc.next(), sc.nextInt()));
        }

        while(true) {
            if (queue.isEmpty()) {
                break;
            }
            Process element = queue.get(0);
            if (element.time > qtm) {
                element.time -= qtm;
                count += qtm;
                queue.remove(0);
                queue.add(element);
            } else {
                count += element.time;
                queue.remove(0);
                System.out.println(element.id + " " + count);
            }
        }
    } main {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int qtm = sc.nextInt();
        int count = 0;
        ArrayList<Process> queue = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            queue.add(new Process(sc.next(), sc.nextInt()));
        }

        while(true) {
            if (queue.isEmpty()) {
                break;
            }
            Process element = queue.get(0);
            if (element.time > qtm) {
                element.time -= qtm;
                count += qtm;
                queue.remove(0);
                queue.add(element);
            } else {
                count += element.time;
                queue.remove(0);
                System.out.println(element.id + " " + count);
            }
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int qtm = sc.nextInt(); qtm sc.nextInt() sc.nextInt sc int count = 0; count 0 ArrayList<Process> queue = new ArrayList<>(); queue new ArrayList<>() for (int i = 0; i < n; i++) {
            queue.add(new Process(sc.next(), sc.nextInt()));
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            queue.add(new Process(sc.next(), sc.nextInt()));
        } {
            queue.add(new Process(sc.next(), sc.nextInt()));
        } queue.add(new Process(sc.next(), sc.nextInt())) queue.add queue new Process(sc.next(), sc.nextInt()) while(true) {
            if (queue.isEmpty()) {
                break;
            }
            Process element = queue.get(0);
            if (element.time > qtm) {
                element.time -= qtm;
                count += qtm;
                queue.remove(0);
                queue.add(element);
            } else {
                count += element.time;
                queue.remove(0);
                System.out.println(element.id + " " + count);
            }
        } true {
            if (queue.isEmpty()) {
                break;
            }
            Process element = queue.get(0);
            if (element.time > qtm) {
                element.time -= qtm;
                count += qtm;
                queue.remove(0);
                queue.add(element);
            } else {
                count += element.time;
                queue.remove(0);
                System.out.println(element.id + " " + count);
            }
        } if (queue.isEmpty()) {
                break;
            } queue.isEmpty() queue.isEmpty queue {
                break;
            } break; Process element = queue.get(0); element queue.get(0) queue.get queue 0 if (element.time > qtm) {
                element.time -= qtm;
                count += qtm;
                queue.remove(0);
                queue.add(element);
            } else {
                count += element.time;
                queue.remove(0);
                System.out.println(element.id + " " + count);
            } element.time > qtm element.time element element.time qtm {
                element.time -= qtm;
                count += qtm;
                queue.remove(0);
                queue.add(element);
            } element.time -= qtm element.time element element.time qtm count += qtm count qtm queue.remove(0) queue.remove queue 0 queue.add(element) queue.add queue element {
                count += element.time;
                queue.remove(0);
                System.out.println(element.id + " " + count);
            } count += element.time count element.time element element.time queue.remove(0) queue.remove queue 0 System.out.println(element.id + " " + count) System.out.println System.out System System.out element.id + " " + count element.id + " " + count element.id element element.id " " count String args[] args public class Main {
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int qtm = sc.nextInt();
        int count = 0;
        ArrayList<Process> queue = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            queue.add(new Process(sc.next(), sc.nextInt()));
        }

        while(true) {
            if (queue.isEmpty()) {
                break;
            }
            Process element = queue.get(0);
            if (element.time > qtm) {
                element.time -= qtm;
                count += qtm;
                queue.remove(0);
                queue.add(element);
            } else {
                count += element.time;
                queue.remove(0);
                System.out.println(element.id + " " + count);
            }
        }
    }
} public class Main {
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int qtm = sc.nextInt();
        int count = 0;
        ArrayList<Process> queue = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            queue.add(new Process(sc.next(), sc.nextInt()));
        }

        while(true) {
            if (queue.isEmpty()) {
                break;
            }
            Process element = queue.get(0);
            if (element.time > qtm) {
                element.time -= qtm;
                count += qtm;
                queue.remove(0);
                queue.add(element);
            } else {
                count += element.time;
                queue.remove(0);
                System.out.println(element.id + " " + count);
            }
        }
    }
} Main

import java.util.*;
import java.lang.*;

class Process {
    String id;
    int time;
    Process(String x, int t) {
        id = x;
        time = t;
    }
}


public class Main {
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int qtm = sc.nextInt();
        int count = 0;
        ArrayList<Process> queue = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            queue.add(new Process(sc.next(), sc.nextInt()));
        }

        while(true) {
            if (queue.isEmpty()) {
                break;
            }
            Process element = queue.get(0);
            if (element.time > qtm) {
                element.time -= qtm;
                count += qtm;
                queue.remove(0);
                queue.add(element);
            } else {
                count += element.time;
                queue.remove(0);
                System.out.println(element.id + " " + count);
            }
        }
    }
}
