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

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

void enqueue(P);
P dequeue();

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

int main(){
  int elaps = 0, c=0;
  int i=0, 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;

  while(elaps<n){

    u = dequeue();

    if(u.t<=100){
      c+=u.t;
      printf("%s %d\n",u.name,c);
      elaps++;
    }
    else{
      c+=100;
      u.t -= 100;
      enqueue(u);
    }
    i++;
  }
  return 0;
}
void enqueue(P x){
  
  if(tail == n)tail = 1;
  else tail++;
  Q[tail] = x;
}
P dequeue(){
  P x;

  x = Q[head];
  if(head == n)head = 1;
  else head++;

  return x;
}
    