#include <stdio.h>
#include <stdlib.h>

#define MAX 100001
typedef struct {
	char name[11];
	int time;
} process;

process Q[MAX] = {0};
int head, tail;

void initialize();
int isEmpty();
int isFull();
void enqueue(process x);
process dequeue();

void showQue(process Que[], int n) {
	int i;
	for (i = 0; i < n; ++i) {
		printf("%s %d\n", Que[i].name, Que[i].time);
	}
	return;
}

int main(void) {
	int n, q, i;
	int stime = 0;
	process tmp_p;
	scanf("%d %d", &n, &q);

	for (i = 0; i < n; ++i) {
		scanf("%s %d", tmp_p.name, &tmp_p.time);
		enqueue(tmp_p);
	}
//	showQue(Q, n);
	while (!isEmpty()) {
		tmp_p = dequeue();
		if (tmp_p.time <= q) {
			stime += tmp_p.time;
			printf("%s %d\n", tmp_p.name, stime);
			continue;
		}

		stime += q;
		tmp_p.time = tmp_p.time - q;

		enqueue(tmp_p);
	}

	return 0;
}

void initialize() {
	head = tail = 0;
}

int isEmpty() {
	return head == tail;
}

int isFull() {
	return head == (tail + 1) % MAX;
}

void enqueue(process x) {
	if (isFull()) {
		printf("Over Flow\n");
		exit(1);
	}

	Q[tail] = x;
	if (tail + 1 == MAX) {
		tail = 0;
	} else {
		tail++;
	}
	
	return;
}

process dequeue() {
	process x;
	if (isEmpty()) {
		printf("Under Flow\n");
		exit(1);
	}
	x = Q[head];
	if (head + 1 == MAX) {
		head = 0;
	} else {
		head++;
	}
	return x;
}