#include<stdio.h>

int main(void){
	int n,q;
	scanf("%d",&n);   scanf("%d",&q);
	
	char qname[n][11];
	int qtime[n];
	int next[n];
	int start=0,end=n-1;
	int tcount=0;
	
	int i;
	scanf("%s",qname[0]);   scanf("%d",&qtime[0]);
	for(i=1;i<n;i++){
		scanf("%s",qname[i]);   scanf("%d",&qtime[i]);
		next[i-1]=i;
		
		//printf("%s\n",qname[i]);
	}
	next[n-1]=-1;
	
	while(start!=-1){
		if(qtime[start]>100){
			qtime[start]-=100;
			next[end]=start;
			end=start;
			start=next[start];
			next[end]=-1;
			tcount+=100;
		}else{
			tcount+=qtime[start];
			printf("%s %d\n",qname[start],tcount);
			start=next[start];
		}
	}		
	return 0;
}
