#include<stdio.h>
#define M 100000

typedef struct{
  char name[10];
  int time;
}Que;

void enqueue(int);
int dequeue(void);
int head=0,tail=0;

 Que p[M];

int main(){
  Que p[M];

  int i,j,n,q,k;

  scanf("%d%d",&n,&q);
    for(i=0;i<n;i++){
      scanf("%s%d",p[i].name,&p[i].time);
      enqueue(p[i].time);
    }
    while(1){
      if(p[i].time>q){
	p[i].time-=q;
	dequeue();

      }
    for(i=0;i<n;i++){
      printf("%s %d",)
	}

}

void enqueue(int x){ 
  int Q[M];
  Q[tail] = x;

  if(Q[tail+1]==M){
    tail=0;
  }

  else tail++;
 
}

int dequeue(){

  int x;
  int Q[M];
  x=Q[head];

  if(Q[head+1]==M){
    head=0;
  }
  else head++;
  return x;
}