#include<stdio.h>
#include<string.h>
#define LEN 100005
#define MAX 1000

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

void initialize(void);
int isEmpty(void);
int isFull(void);
void enqueue(P);
P dequeue(void);

P Q[LEN+1],A[LEN+1];
int head, tail, n;

void enqueue(P x){
  if(isFull() == 1) fprintf(stderr,"Error(overflow)\n");
  Q[tail] = x;
  if(tail + 1 == MAX) tail = 0;
  else tail++;
}


P dequeue(void){
  P x;
  if(isEmpty() == 1) fprintf(stderr,"Error(underflow)\n");
  x = Q[head];
  if(head + 1 == MAX) head = 0;
  else head++;
  return x;
}


int main(){
  int elaps = 0, c = 0;
  int i,j=1,q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  
  head = 1;
  tail = n+1;
  
  while(1){
    u = dequeue();
    elaps = u.t - q;  
    if(elaps > 0){
      c += 100;
      u.t = elaps;
      enqueue(u);
    }
    else if(elaps <= 0){
      c += u.t;
      strcpy(A[j].name,u.name);
      A[j].t = c;
      j++;
    }
    if(isEmpty() == 1) break;
  }

  printf("\n");
  for ( i = 1; i <= n; i++){
    printf("%s ", A[i].name);
    printf("%d", A[i].t);
    printf("\n");
  }
  
  return 0;
}

void initialize(void){
  head = tail = 0;
}

int isEmpty(void){
  if(head == tail) return 1;
  else return 0;
}

int isFull(void){
  if(head == (tail + 1) % MAX) return 1;
  else return 0;
}