#include <stdio.h>
#include <string.h>
#define LEN 100000

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

P Q[LEN+1];
P R[LEN+1];
int head=0, tail=0,n;

void enqueue(P);

P dequeue(P);

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

  for(i=1;i<=n;i++){
    scanf("%s %d ",Q[i].name ,&Q[i].t);
    enqueue(Q[i]);
  }

  while(1){
    Q[head].t-=100;
    u=dequeue(Q[head]);
    if(Q[head].t>0) enqueue(u);
    else{ R[j]=u;
      j++;}
    if(head==tail) break;
  }
    for(i=1;i<=n;i++){
      printf("%s %d\n",R[i].name,R[i].t);
    }

  return 0;
}

void enqueue(P x){
  Q[tail]=x;
  if(tail+1==LEN) tail=0;
  else tail++;
}

P dequeue(P x){
  x=Q[head];
  if(head+1==LEN) head=0;
  else head++;

  return x;
}