import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String[] line = br.readLine().split(" ");
      int n     = Integer.parseInt(line[0]);
      int qTime = Integer.parseInt(line[1]);
      Queue<Process> queue = new Queue<>(n*2);

      for(int i=0; i!=n; i++) {
        line = br.readLine().split(" ");
        queue.enQueue( new Process(line[0], Integer.parseInt(line[1])) );
      }

      int usingTime = 0;
      Process proc;
      StringBuilder result = new StringBuilder(n*5);

      while(!queue.isEmpty()) {
        proc = queue.deQueue();
        proc.pTime -= qTime;

        if(proc.pTime < 1) {
          usingTime += qTime + proc.pTime;
          result.append(proc.name).append(" ").append(usingTime).append("\n"); 
        } else {
          usingTime += qTime;
          queue.enQueue(proc);
        }
      }

      System.out.print(result);
    }
  }
}

class Process {
  final String name;
  int pTime;

  public Process(String name, int time) {
    this.name = name;
    this.pTime = time;
  }
}

class Queue<E> {

  private Object[] queue;
  private int head;
  private int tail;
  private int max;

  public Queue(int capacity) {
    queue = new Object[capacity];
    head = tail = 0;
    max  = queue.length;
  }

  boolean isEmpty() {
    return head == tail;
  }
  boolean isFull() {
    return head == (tail + 1) % max;
  }

  void enQueue(E x) {
    if(isFull()) System.out.println("queue is full!");

    queue[tail] = x;
    if(tail+1 == max) tail = 0;
    else tail++;
  }
  @SuppressWarnings("unchecked")
  E deQueue() {
    if(isEmpty()) {
      System.out.println("queue is empty!");
      throw new IllegalStateException("queue is empty!");
    }

    E ret = (E)queue[head];

    if(head+1 == max) head = 0;
    else head++;

    return ret;
  }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String[] line = br.readLine().split(" ");
      int n     = Integer.parseInt(line[0]);
      int qTime = Integer.parseInt(line[1]);
      Queue<Process> queue = new Queue<>(n*2);

      for(int i=0; i!=n; i++) {
        line = br.readLine().split(" ");
        queue.enQueue( new Process(line[0], Integer.parseInt(line[1])) );
      }

      int usingTime = 0;
      Process proc;
      StringBuilder result = new StringBuilder(n*5);

      while(!queue.isEmpty()) {
        proc = queue.deQueue();
        proc.pTime -= qTime;

        if(proc.pTime < 1) {
          usingTime += qTime + proc.pTime;
          result.append(proc.name).append(" ").append(usingTime).append("\n"); 
        } else {
          usingTime += qTime;
          queue.enQueue(proc);
        }
      }

      System.out.print(result);
    }
  }
} Main public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String[] line = br.readLine().split(" ");
      int n     = Integer.parseInt(line[0]);
      int qTime = Integer.parseInt(line[1]);
      Queue<Process> queue = new Queue<>(n*2);

      for(int i=0; i!=n; i++) {
        line = br.readLine().split(" ");
        queue.enQueue( new Process(line[0], Integer.parseInt(line[1])) );
      }

      int usingTime = 0;
      Process proc;
      StringBuilder result = new StringBuilder(n*5);

      while(!queue.isEmpty()) {
        proc = queue.deQueue();
        proc.pTime -= qTime;

        if(proc.pTime < 1) {
          usingTime += qTime + proc.pTime;
          result.append(proc.name).append(" ").append(usingTime).append("\n"); 
        } else {
          usingTime += qTime;
          queue.enQueue(proc);
        }
      }

      System.out.print(result);
    }
  } main {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String[] line = br.readLine().split(" ");
      int n     = Integer.parseInt(line[0]);
      int qTime = Integer.parseInt(line[1]);
      Queue<Process> queue = new Queue<>(n*2);

      for(int i=0; i!=n; i++) {
        line = br.readLine().split(" ");
        queue.enQueue( new Process(line[0], Integer.parseInt(line[1])) );
      }

      int usingTime = 0;
      Process proc;
      StringBuilder result = new StringBuilder(n*5);

      while(!queue.isEmpty()) {
        proc = queue.deQueue();
        proc.pTime -= qTime;

        if(proc.pTime < 1) {
          usingTime += qTime + proc.pTime;
          result.append(proc.name).append(" ").append(usingTime).append("\n"); 
        } else {
          usingTime += qTime;
          queue.enQueue(proc);
        }
      }

      System.out.print(result);
    }
  } try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String[] line = br.readLine().split(" ");
      int n     = Integer.parseInt(line[0]);
      int qTime = Integer.parseInt(line[1]);
      Queue<Process> queue = new Queue<>(n*2);

      for(int i=0; i!=n; i++) {
        line = br.readLine().split(" ");
        queue.enQueue( new Process(line[0], Integer.parseInt(line[1])) );
      }

      int usingTime = 0;
      Process proc;
      StringBuilder result = new StringBuilder(n*5);

      while(!queue.isEmpty()) {
        proc = queue.deQueue();
        proc.pTime -= qTime;

        if(proc.pTime < 1) {
          usingTime += qTime + proc.pTime;
          result.append(proc.name).append(" ").append(usingTime).append("\n"); 
        } else {
          usingTime += qTime;
          queue.enQueue(proc);
        }
      }

      System.out.print(result);
    } {

      String[] line = br.readLine().split(" ");
      int n     = Integer.parseInt(line[0]);
      int qTime = Integer.parseInt(line[1]);
      Queue<Process> queue = new Queue<>(n*2);

      for(int i=0; i!=n; i++) {
        line = br.readLine().split(" ");
        queue.enQueue( new Process(line[0], Integer.parseInt(line[1])) );
      }

      int usingTime = 0;
      Process proc;
      StringBuilder result = new StringBuilder(n*5);

      while(!queue.isEmpty()) {
        proc = queue.deQueue();
        proc.pTime -= qTime;

        if(proc.pTime < 1) {
          usingTime += qTime + proc.pTime;
          result.append(proc.name).append(" ").append(usingTime).append("\n"); 
        } else {
          usingTime += qTime;
          queue.enQueue(proc);
        }
      }

      System.out.print(result);
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) new BufferedReader(new InputStreamReader(System.in)) String[] line = br.readLine().split(" "); line br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int n     = Integer.parseInt(line[0]); n Integer.parseInt(line[0]) Integer.parseInt Integer line[0] line 0 int qTime = Integer.parseInt(line[1]); qTime Integer.parseInt(line[1]) Integer.parseInt Integer line[1] line 1 Queue<Process> queue = new Queue<>(n*2); queue new Queue<>(n*2) for(int i=0; i!=n; i++) {
        line = br.readLine().split(" ");
        queue.enQueue( new Process(line[0], Integer.parseInt(line[1])) );
      } int i=0; int i=0; i 0 i!=n i n i++ i++ i {
        line = br.readLine().split(" ");
        queue.enQueue( new Process(line[0], Integer.parseInt(line[1])) );
      } {
        line = br.readLine().split(" ");
        queue.enQueue( new Process(line[0], Integer.parseInt(line[1])) );
      } line = br.readLine().split(" ") line br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " queue.enQueue( new Process(line[0], Integer.parseInt(line[1])) ) queue.enQueue queue new Process(line[0], Integer.parseInt(line[1])) int usingTime = 0; usingTime 0 Process proc; proc StringBuilder result = new StringBuilder(n*5); result new StringBuilder(n*5) while(!queue.isEmpty()) {
        proc = queue.deQueue();
        proc.pTime -= qTime;

        if(proc.pTime < 1) {
          usingTime += qTime + proc.pTime;
          result.append(proc.name).append(" ").append(usingTime).append("\n"); 
        } else {
          usingTime += qTime;
          queue.enQueue(proc);
        }
      } !queue.isEmpty() queue.isEmpty() queue.isEmpty queue {
        proc = queue.deQueue();
        proc.pTime -= qTime;

        if(proc.pTime < 1) {
          usingTime += qTime + proc.pTime;
          result.append(proc.name).append(" ").append(usingTime).append("\n"); 
        } else {
          usingTime += qTime;
          queue.enQueue(proc);
        }
      } proc = queue.deQueue() proc queue.deQueue() queue.deQueue queue proc.pTime -= qTime proc.pTime proc proc.pTime qTime if(proc.pTime < 1) {
          usingTime += qTime + proc.pTime;
          result.append(proc.name).append(" ").append(usingTime).append("\n"); 
        } else {
          usingTime += qTime;
          queue.enQueue(proc);
        } proc.pTime < 1 proc.pTime proc proc.pTime 1 {
          usingTime += qTime + proc.pTime;
          result.append(proc.name).append(" ").append(usingTime).append("\n"); 
        } usingTime += qTime + proc.pTime usingTime qTime + proc.pTime qTime proc.pTime proc proc.pTime result.append(proc.name).append(" ").append(usingTime).append("\n") result.append(proc.name).append(" ").append(usingTime).append result.append(proc.name).append(" ").append(usingTime) result.append(proc.name).append(" ").append result.append(proc.name).append(" ") result.append(proc.name).append result.append(proc.name) result.append result proc.name proc proc.name " " usingTime "\n" {
          usingTime += qTime;
          queue.enQueue(proc);
        } usingTime += qTime usingTime qTime queue.enQueue(proc) queue.enQueue queue proc System.out.print(result) System.out.print System.out System System.out result String[] args args class Process {
  final String name;
  int pTime;

  public Process(String name, int time) {
    this.name = name;
    this.pTime = time;
  }
} Process final String name; name int pTime; pTime public Process(String name, int time) {
    this.name = name;
    this.pTime = time;
  } Process {
    this.name = name;
    this.pTime = time;
  } this.name = name this.name this this.name name this.pTime = time this.pTime this this.pTime time String name name int time time class Queue<E> {

  private Object[] queue;
  private int head;
  private int tail;
  private int max;

  public Queue(int capacity) {
    queue = new Object[capacity];
    head = tail = 0;
    max  = queue.length;
  }

  boolean isEmpty() {
    return head == tail;
  }
  boolean isFull() {
    return head == (tail + 1) % max;
  }

  void enQueue(E x) {
    if(isFull()) System.out.println("queue is full!");

    queue[tail] = x;
    if(tail+1 == max) tail = 0;
    else tail++;
  }
  @SuppressWarnings("unchecked")
  E deQueue() {
    if(isEmpty()) {
      System.out.println("queue is empty!");
      throw new IllegalStateException("queue is empty!");
    }

    E ret = (E)queue[head];

    if(head+1 == max) head = 0;
    else head++;

    return ret;
  }
} Queue private Object[] queue; queue private int head; head private int tail; tail private int max; max public Queue(int capacity) {
    queue = new Object[capacity];
    head = tail = 0;
    max  = queue.length;
  } Queue {
    queue = new Object[capacity];
    head = tail = 0;
    max  = queue.length;
  } queue = new Object[capacity] queue new Object[capacity] capacity head = tail = 0 head tail = 0 tail 0 max  = queue.length max queue.length queue queue.length int capacity capacity boolean isEmpty() {
    return head == tail;
  } isEmpty {
    return head == tail;
  } return head == tail; head == tail head tail boolean isFull() {
    return head == (tail + 1) % max;
  } isFull {
    return head == (tail + 1) % max;
  } return head == (tail + 1) % max; head == (tail + 1) % max head (tail + 1) % max (tail + 1) tail 1 max void enQueue(E x) {
    if(isFull()) System.out.println("queue is full!");

    queue[tail] = x;
    if(tail+1 == max) tail = 0;
    else tail++;
  } enQueue {
    if(isFull()) System.out.println("queue is full!");

    queue[tail] = x;
    if(tail+1 == max) tail = 0;
    else tail++;
  } if(isFull()) System.out.println("queue is full!"); isFull() isFull System.out.println("queue is full!") System.out.println System.out System System.out "queue is full!" queue[tail] = x queue[tail] queue tail x if(tail+1 == max) tail = 0;
    else tail++; tail+1 == max tail+1 tail 1 max tail = 0 tail 0 tail++ tail E x x @SuppressWarnings("unchecked")
  E deQueue() {
    if(isEmpty()) {
      System.out.println("queue is empty!");
      throw new IllegalStateException("queue is empty!");
    }

    E ret = (E)queue[head];

    if(head+1 == max) head = 0;
    else head++;

    return ret;
  } deQueue {
    if(isEmpty()) {
      System.out.println("queue is empty!");
      throw new IllegalStateException("queue is empty!");
    }

    E ret = (E)queue[head];

    if(head+1 == max) head = 0;
    else head++;

    return ret;
  } if(isEmpty()) {
      System.out.println("queue is empty!");
      throw new IllegalStateException("queue is empty!");
    } isEmpty() isEmpty {
      System.out.println("queue is empty!");
      throw new IllegalStateException("queue is empty!");
    } System.out.println("queue is empty!") System.out.println System.out System System.out "queue is empty!" throw new IllegalStateException("queue is empty!"); new IllegalStateException("queue is empty!") E ret = (E)queue[head]; ret (E)queue[head] queue head if(head+1 == max) head = 0;
    else head++; head+1 == max head+1 head 1 max head = 0 head 0 head++ head return ret; ret public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String[] line = br.readLine().split(" ");
      int n     = Integer.parseInt(line[0]);
      int qTime = Integer.parseInt(line[1]);
      Queue<Process> queue = new Queue<>(n*2);

      for(int i=0; i!=n; i++) {
        line = br.readLine().split(" ");
        queue.enQueue( new Process(line[0], Integer.parseInt(line[1])) );
      }

      int usingTime = 0;
      Process proc;
      StringBuilder result = new StringBuilder(n*5);

      while(!queue.isEmpty()) {
        proc = queue.deQueue();
        proc.pTime -= qTime;

        if(proc.pTime < 1) {
          usingTime += qTime + proc.pTime;
          result.append(proc.name).append(" ").append(usingTime).append("\n"); 
        } else {
          usingTime += qTime;
          queue.enQueue(proc);
        }
      }

      System.out.print(result);
    }
  }
} public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String[] line = br.readLine().split(" ");
      int n     = Integer.parseInt(line[0]);
      int qTime = Integer.parseInt(line[1]);
      Queue<Process> queue = new Queue<>(n*2);

      for(int i=0; i!=n; i++) {
        line = br.readLine().split(" ");
        queue.enQueue( new Process(line[0], Integer.parseInt(line[1])) );
      }

      int usingTime = 0;
      Process proc;
      StringBuilder result = new StringBuilder(n*5);

      while(!queue.isEmpty()) {
        proc = queue.deQueue();
        proc.pTime -= qTime;

        if(proc.pTime < 1) {
          usingTime += qTime + proc.pTime;
          result.append(proc.name).append(" ").append(usingTime).append("\n"); 
        } else {
          usingTime += qTime;
          queue.enQueue(proc);
        }
      }

      System.out.print(result);
    }
  }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String[] line = br.readLine().split(" ");
      int n     = Integer.parseInt(line[0]);
      int qTime = Integer.parseInt(line[1]);
      Queue<Process> queue = new Queue<>(n*2);

      for(int i=0; i!=n; i++) {
        line = br.readLine().split(" ");
        queue.enQueue( new Process(line[0], Integer.parseInt(line[1])) );
      }

      int usingTime = 0;
      Process proc;
      StringBuilder result = new StringBuilder(n*5);

      while(!queue.isEmpty()) {
        proc = queue.deQueue();
        proc.pTime -= qTime;

        if(proc.pTime < 1) {
          usingTime += qTime + proc.pTime;
          result.append(proc.name).append(" ").append(usingTime).append("\n"); 
        } else {
          usingTime += qTime;
          queue.enQueue(proc);
        }
      }

      System.out.print(result);
    }
  }
}

class Process {
  final String name;
  int pTime;

  public Process(String name, int time) {
    this.name = name;
    this.pTime = time;
  }
}

class Queue<E> {

  private Object[] queue;
  private int head;
  private int tail;
  private int max;

  public Queue(int capacity) {
    queue = new Object[capacity];
    head = tail = 0;
    max  = queue.length;
  }

  boolean isEmpty() {
    return head == tail;
  }
  boolean isFull() {
    return head == (tail + 1) % max;
  }

  void enQueue(E x) {
    if(isFull()) System.out.println("queue is full!");

    queue[tail] = x;
    if(tail+1 == max) tail = 0;
    else tail++;
  }
  @SuppressWarnings("unchecked")
  E deQueue() {
    if(isEmpty()) {
      System.out.println("queue is empty!");
      throw new IllegalStateException("queue is empty!");
    }

    E ret = (E)queue[head];

    if(head+1 == max) head = 0;
    else head++;

    return ret;
  }
}
