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

struct Queue {
  int time;
  char name[7];
  struct Queue *next;
};

void push(int a, char nam[7]);

struct Queue *top = NULL, *bot = NULL;

int main(void){
int n, i, num, ans = 0, tmp;
char str[7];
scanf("%d %d",&n, &num);
for (i=0;i<n;i++) {
scanf("%s %d",str,&tmp);
push(tmp,str);
}
while(bot != NULL) {
if(bot->time <= num) {
ans += bot->time;
printf("%s %d?\n",bot->name,ans);
bot = bot->next;
} else {
ans += num;
bot->time -= num;
push(bot->time,bot->name);
bot = bot->next;
}}
return 0;
}

void push(int a, char nam[7]){
struct Queue *new;
new = (struct Queue *)malloc(sizeof(struct Queue));
new->time = a;
strcpy(nam,new->name);
new->next = NULL;
top->next = new;
top = new;
}