#include<stdio.h>
#include<stdlib.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
} P;

P Q[LEN+1];

int head,tail,n;
int isEmpty(){
  return head==tail;
}

int isFull(){
  return head==(tail+1)%LEN;
}

void enqueue(P x){
  if(isFull()){
    printf("Overflow\n");
    exit(2);
  }
  Q[tail]=x;
  if(tail+1==LEN) tail=0;
  else tail++;
}

P dequeue(){
  P x;
  if(isEmpty()){
    printf("Empty\n");
    exit(3);
  }
  x=Q[head];
  if(head+1==LEN) head=0;
  else head++;
  return x;
}
  

int main(){
  int elaps=0,c;
  int i,q;
  P u;
  head=1;
  tail=0;
  scanf("%d %d",&n,&q);
  tail=n+1;
  for(i=1;i<=n;i++){
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].t);
  }
  //printf("\n");
  while(head!=tail){
    u=dequeue();
    if(u.t-q<=0){
      elaps+=u.t;
      printf("%s %d\n",u.name,elaps);
    }
    else {
      elaps+=q;
      u.t-=q;
      enqueue(u);
    }
  }
  return 0;
}

