import java.util.List;
import java.util.ArrayList;
import java.util.HashMap;

import java.util.Scanner;

public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        Queue<Pair<String, Integer>> queue = new Queue<>();
        
        int n = sc.nextInt();
        int q = sc.nextInt();
        
        for (int i = 0; i < n; i++) {
            queue.enqueue(new Pair<String, Integer>(sc.next(), sc.nextInt()));
        }
        
        long pass = 0;
        
        while (!queue.isEmpty()) {
            Pair<String, Integer> p = queue.dequeue();
            int i = p.getValue() - q;
            if (i <= 0) {
                pass += (q + i);
                System.out.println(p.getKey() + " " + pass);
            } else {
                pass += q;
                p.setValue(i);
                queue.enqueue(p);
            }
        }
    }
}

class Stack<T> {
    private List<T> list;
    
    public Stack() {
        list = new ArrayList<>();
    }
    
    public void push(T t) {
        list.add(t);
    }
    
    public T pop() {
        T t = list.get(list.size()-1);
        list.remove(list.size()-1);
        return t;
    }
    
    public boolean isEmpty() {
        return list.isEmpty();
    }
}

class Queue<T> {
    Node<T> head;
    Node<T> tail;
    
    public void enqueue(T t) {
        Node<T> n = new Node<>(t);
        if (head == null) head = n;
        if (tail != null) {
            tail.next = n;
            n.prev = tail;
        }
        tail = n;
    }
    
    public T dequeue() {
        T t = head.elem;
        head = head.next;
        if (head != null) {
            head.prev = null;
        } else {
            tail = null;
        }
        return t;
    }
    
    public boolean isEmpty() {
        return head == null && tail == null;
    }
}

class Node<T> {
    T elem;
    Node<T> prev;
    Node<T> next;
    public Node(T t) { elem = t; }
}

class Pair<K, V> {
    K k;
    V v;
    public K getKey() { return k; }
    public void setKey(K k) { this.k = k; }
    public V getValue() { return v; }
    public void setValue(V v) { this.v = v; }
    public Pair(K k, V v) {
        this.k = k;
        this.v = v;
    }
} import java.util.List; List java.util import java.util.ArrayList; ArrayList java.util import java.util.HashMap; HashMap java.util import java.util.Scanner; Scanner java.util public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        Queue<Pair<String, Integer>> queue = new Queue<>();
        
        int n = sc.nextInt();
        int q = sc.nextInt();
        
        for (int i = 0; i < n; i++) {
            queue.enqueue(new Pair<String, Integer>(sc.next(), sc.nextInt()));
        }
        
        long pass = 0;
        
        while (!queue.isEmpty()) {
            Pair<String, Integer> p = queue.dequeue();
            int i = p.getValue() - q;
            if (i <= 0) {
                pass += (q + i);
                System.out.println(p.getKey() + " " + pass);
            } else {
                pass += q;
                p.setValue(i);
                queue.enqueue(p);
            }
        }
    }
} Main private static Scanner sc = new Scanner(System.in); sc new Scanner(System.in) public static void main(String[] args) {
        Queue<Pair<String, Integer>> queue = new Queue<>();
        
        int n = sc.nextInt();
        int q = sc.nextInt();
        
        for (int i = 0; i < n; i++) {
            queue.enqueue(new Pair<String, Integer>(sc.next(), sc.nextInt()));
        }
        
        long pass = 0;
        
        while (!queue.isEmpty()) {
            Pair<String, Integer> p = queue.dequeue();
            int i = p.getValue() - q;
            if (i <= 0) {
                pass += (q + i);
                System.out.println(p.getKey() + " " + pass);
            } else {
                pass += q;
                p.setValue(i);
                queue.enqueue(p);
            }
        }
    } main {
        Queue<Pair<String, Integer>> queue = new Queue<>();
        
        int n = sc.nextInt();
        int q = sc.nextInt();
        
        for (int i = 0; i < n; i++) {
            queue.enqueue(new Pair<String, Integer>(sc.next(), sc.nextInt()));
        }
        
        long pass = 0;
        
        while (!queue.isEmpty()) {
            Pair<String, Integer> p = queue.dequeue();
            int i = p.getValue() - q;
            if (i <= 0) {
                pass += (q + i);
                System.out.println(p.getKey() + " " + pass);
            } else {
                pass += q;
                p.setValue(i);
                queue.enqueue(p);
            }
        }
    } Queue<Pair<String, Integer>> queue = new Queue<>(); queue new Queue<>() int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int q = sc.nextInt(); q sc.nextInt() sc.nextInt sc for (int i = 0; i < n; i++) {
            queue.enqueue(new Pair<String, Integer>(sc.next(), sc.nextInt()));
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            queue.enqueue(new Pair<String, Integer>(sc.next(), sc.nextInt()));
        } {
            queue.enqueue(new Pair<String, Integer>(sc.next(), sc.nextInt()));
        } queue.enqueue(new Pair<String, Integer>(sc.next(), sc.nextInt())) queue.enqueue queue new Pair<String, Integer>(sc.next(), sc.nextInt()) long pass = 0; pass 0 while (!queue.isEmpty()) {
            Pair<String, Integer> p = queue.dequeue();
            int i = p.getValue() - q;
            if (i <= 0) {
                pass += (q + i);
                System.out.println(p.getKey() + " " + pass);
            } else {
                pass += q;
                p.setValue(i);
                queue.enqueue(p);
            }
        } !queue.isEmpty() queue.isEmpty() queue.isEmpty queue {
            Pair<String, Integer> p = queue.dequeue();
            int i = p.getValue() - q;
            if (i <= 0) {
                pass += (q + i);
                System.out.println(p.getKey() + " " + pass);
            } else {
                pass += q;
                p.setValue(i);
                queue.enqueue(p);
            }
        } Pair<String, Integer> p = queue.dequeue(); p queue.dequeue() queue.dequeue queue int i = p.getValue() - q; i p.getValue() - q p.getValue() p.getValue p q if (i <= 0) {
                pass += (q + i);
                System.out.println(p.getKey() + " " + pass);
            } else {
                pass += q;
                p.setValue(i);
                queue.enqueue(p);
            } i <= 0 i 0 {
                pass += (q + i);
                System.out.println(p.getKey() + " " + pass);
            } pass += (q + i) pass (q + i) q i System.out.println(p.getKey() + " " + pass) System.out.println System.out System System.out p.getKey() + " " + pass p.getKey() + " " + pass p.getKey() p.getKey p " " pass {
                pass += q;
                p.setValue(i);
                queue.enqueue(p);
            } pass += q pass q p.setValue(i) p.setValue p i queue.enqueue(p) queue.enqueue queue p String[] args args class Stack<T> {
    private List<T> list;
    
    public Stack() {
        list = new ArrayList<>();
    }
    
    public void push(T t) {
        list.add(t);
    }
    
    public T pop() {
        T t = list.get(list.size()-1);
        list.remove(list.size()-1);
        return t;
    }
    
    public boolean isEmpty() {
        return list.isEmpty();
    }
} Stack private List<T> list; list public Stack() {
        list = new ArrayList<>();
    } Stack {
        list = new ArrayList<>();
    } list = new ArrayList<>() list new ArrayList<>() public void push(T t) {
        list.add(t);
    } push {
        list.add(t);
    } list.add(t) list.add list t T t t public T pop() {
        T t = list.get(list.size()-1);
        list.remove(list.size()-1);
        return t;
    } pop {
        T t = list.get(list.size()-1);
        list.remove(list.size()-1);
        return t;
    } T t = list.get(list.size()-1); t list.get(list.size()-1) list.get list list.size()-1 list.size() list.size list 1 list.remove(list.size()-1) list.remove list list.size()-1 list.size() list.size list 1 return t; t public boolean isEmpty() {
        return list.isEmpty();
    } isEmpty {
        return list.isEmpty();
    } return list.isEmpty(); list.isEmpty() list.isEmpty list class Queue<T> {
    Node<T> head;
    Node<T> tail;
    
    public void enqueue(T t) {
        Node<T> n = new Node<>(t);
        if (head == null) head = n;
        if (tail != null) {
            tail.next = n;
            n.prev = tail;
        }
        tail = n;
    }
    
    public T dequeue() {
        T t = head.elem;
        head = head.next;
        if (head != null) {
            head.prev = null;
        } else {
            tail = null;
        }
        return t;
    }
    
    public boolean isEmpty() {
        return head == null && tail == null;
    }
} Queue Node<T> head; head Node<T> tail; tail public void enqueue(T t) {
        Node<T> n = new Node<>(t);
        if (head == null) head = n;
        if (tail != null) {
            tail.next = n;
            n.prev = tail;
        }
        tail = n;
    } enqueue {
        Node<T> n = new Node<>(t);
        if (head == null) head = n;
        if (tail != null) {
            tail.next = n;
            n.prev = tail;
        }
        tail = n;
    } Node<T> n = new Node<>(t); n new Node<>(t) if (head == null) head = n; head == null head null head = n head n if (tail != null) {
            tail.next = n;
            n.prev = tail;
        } tail != null tail null {
            tail.next = n;
            n.prev = tail;
        } tail.next = n tail.next tail tail.next n n.prev = tail n.prev n n.prev tail tail = n tail n T t t public T dequeue() {
        T t = head.elem;
        head = head.next;
        if (head != null) {
            head.prev = null;
        } else {
            tail = null;
        }
        return t;
    } dequeue {
        T t = head.elem;
        head = head.next;
        if (head != null) {
            head.prev = null;
        } else {
            tail = null;
        }
        return t;
    } T t = head.elem; t head.elem head head.elem head = head.next head head.next head head.next if (head != null) {
            head.prev = null;
        } else {
            tail = null;
        } head != null head null {
            head.prev = null;
        } head.prev = null head.prev head head.prev null {
            tail = null;
        } tail = null tail null return t; t public boolean isEmpty() {
        return head == null && tail == null;
    } isEmpty {
        return head == null && tail == null;
    } return head == null && tail == null; head == null && tail == null head == null head null tail == null tail null class Node<T> {
    T elem;
    Node<T> prev;
    Node<T> next;
    public Node(T t) { elem = t; }
} Node T elem; elem Node<T> prev; prev Node<T> next; next public Node(T t) { elem = t; } Node { elem = t; } elem = t elem t T t t class Pair<K, V> {
    K k;
    V v;
    public K getKey() { return k; }
    public void setKey(K k) { this.k = k; }
    public V getValue() { return v; }
    public void setValue(V v) { this.v = v; }
    public Pair(K k, V v) {
        this.k = k;
        this.v = v;
    }
} Pair K k; k V v; v public K getKey() { return k; } getKey { return k; } return k; k public void setKey(K k) { this.k = k; } setKey { this.k = k; } this.k = k this.k this this.k k K k k public V getValue() { return v; } getValue { return v; } return v; v public void setValue(V v) { this.v = v; } setValue { this.v = v; } this.v = v this.v this this.v v V v v public Pair(K k, V v) {
        this.k = k;
        this.v = v;
    } Pair {
        this.k = k;
        this.v = v;
    } this.k = k this.k this this.k k this.v = v this.v this this.v v K k k V v v public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        Queue<Pair<String, Integer>> queue = new Queue<>();
        
        int n = sc.nextInt();
        int q = sc.nextInt();
        
        for (int i = 0; i < n; i++) {
            queue.enqueue(new Pair<String, Integer>(sc.next(), sc.nextInt()));
        }
        
        long pass = 0;
        
        while (!queue.isEmpty()) {
            Pair<String, Integer> p = queue.dequeue();
            int i = p.getValue() - q;
            if (i <= 0) {
                pass += (q + i);
                System.out.println(p.getKey() + " " + pass);
            } else {
                pass += q;
                p.setValue(i);
                queue.enqueue(p);
            }
        }
    }
} public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        Queue<Pair<String, Integer>> queue = new Queue<>();
        
        int n = sc.nextInt();
        int q = sc.nextInt();
        
        for (int i = 0; i < n; i++) {
            queue.enqueue(new Pair<String, Integer>(sc.next(), sc.nextInt()));
        }
        
        long pass = 0;
        
        while (!queue.isEmpty()) {
            Pair<String, Integer> p = queue.dequeue();
            int i = p.getValue() - q;
            if (i <= 0) {
                pass += (q + i);
                System.out.println(p.getKey() + " " + pass);
            } else {
                pass += q;
                p.setValue(i);
                queue.enqueue(p);
            }
        }
    }
} Main
import java.util.List;
import java.util.ArrayList;
import java.util.HashMap;

import java.util.Scanner;

public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        Queue<Pair<String, Integer>> queue = new Queue<>();
        
        int n = sc.nextInt();
        int q = sc.nextInt();
        
        for (int i = 0; i < n; i++) {
            queue.enqueue(new Pair<String, Integer>(sc.next(), sc.nextInt()));
        }
        
        long pass = 0;
        
        while (!queue.isEmpty()) {
            Pair<String, Integer> p = queue.dequeue();
            int i = p.getValue() - q;
            if (i <= 0) {
                pass += (q + i);
                System.out.println(p.getKey() + " " + pass);
            } else {
                pass += q;
                p.setValue(i);
                queue.enqueue(p);
            }
        }
    }
}

class Stack<T> {
    private List<T> list;
    
    public Stack() {
        list = new ArrayList<>();
    }
    
    public void push(T t) {
        list.add(t);
    }
    
    public T pop() {
        T t = list.get(list.size()-1);
        list.remove(list.size()-1);
        return t;
    }
    
    public boolean isEmpty() {
        return list.isEmpty();
    }
}

class Queue<T> {
    Node<T> head;
    Node<T> tail;
    
    public void enqueue(T t) {
        Node<T> n = new Node<>(t);
        if (head == null) head = n;
        if (tail != null) {
            tail.next = n;
            n.prev = tail;
        }
        tail = n;
    }
    
    public T dequeue() {
        T t = head.elem;
        head = head.next;
        if (head != null) {
            head.prev = null;
        } else {
            tail = null;
        }
        return t;
    }
    
    public boolean isEmpty() {
        return head == null && tail == null;
    }
}

class Node<T> {
    T elem;
    Node<T> prev;
    Node<T> next;
    public Node(T t) { elem = t; }
}

class Pair<K, V> {
    K k;
    V v;
    public K getKey() { return k; }
    public void setKey(K k) { this.k = k; }
    public V getValue() { return v; }
    public void setValue(V v) { this.v = v; }
    public Pair(K k, V v) {
        this.k = k;
        this.v = v;
    }
}