#include<stdio.h>

void enqueue(int );
int dequeue();
int time[1000];
char name[1000][10];
int head=0,tail=0,n,q;

int main(){
  int i,total=0,flag=1;
  
  // input
  scanf("%d%d",&n,&q);
  for(i=0;i<n;i++){
    scanf("%s%d",name[i],&time[i]);
  }
  
  // execute
  while(1){
    flag = 0;
    for(i=0;i<n;i++){
      if(time[i] <= 100 && time[i] > 0){
	total += time[i];
	time[i] = 0;
	printf("%s %d\n",name[i],total);
      }
      else if(time[i] > 100){
	total += 100;
	time[i] -= 100;
	flag = 1;
      }
    }
    if(flag == 0) break;
  }
  
  
  return 0;