#include<stdio.h>
#include<string.h>
int d;
int q;

struct Process{
  char name[100];
  int t;
};

struct Process Q[1000];
int n;

void enqueue(struct Process x){
  int i;
  for(i=0;i<n;i++){
    Q[i]=Q[i+1];
  }
  Q[i-1]=x;
}

struct Process dequeue(){
  int i;
  for(i=0;i<q/10;i++,d+=10){
     Q[0].t-=10;
   if(Q[0].t<=0){
      if(Q[0].t==0){
	d+=10;
	printf("%s %d\n",Q[0].name,d);
	Q[0].t-=10;
      }
      return Q[0];
    }

  }
  return Q[0];
}

int main(){
  int i,j;
  int count;
  scanf("%d %d", &n, &q);
  
  for ( i = 0; i < n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  
  while(1){
    count=0;
    for(i=0;i<n;i++){
      enqueue(dequeue());
      if(Q[i].t<=0)count++;
    }
      if(count==n)break;   
  }
  return 0;
}