#include<stdio.h>
#include<string.h>
int main() {
	int n, q,i,emiya,st,j;
	char name[100000][10];
	char NBK[10000][10];
	int time[100000];
	int emiyaS[100000];

	scanf("%d%d",&n,&q);
	for (i = 0; i < n; i++) {
		scanf("%s%d", name[i], &time[i]);
	}
	i = 0;
	while (time[n - 1] > 0) {
		st=time[i] - q;
		if (st > 0) {
			for (j = 0; j < n-1; j++) {
				time[j] = time[j + 1];
			}
			time[n - 1] = st;
			emiya += 100;
		}
		else {
			strcpy(NBK[i], name[i]);
			emiya += -time[i];
			emiyaS[i] = emiya;
		}
		i++;
	}
	
	for (i = 0; i < n; i++) {
		printf("%s%d", NBK[i], emiyaS[i]);
	}

}
