#include<stdio.h>
#include<string.h>
 
typedef struct{
  char name[20];
  int num;
    }Name;
 
#define M 100000
#define TRUE 1
#define FALSE 0
 
//void initialize(int,int);
void enqueue(Name);
Name dequeue(void);
int isEmpty(int,int);
int isFULL(int,int);
 
int i,j,N,time=0,sumtime=0,time2,quantum;
int head,tail;
 
Name Q[M],de;
 
int main(){
 
  scanf("%d",&N);
  scanf("%d",&quantum);
 
  for(i=0;i<N;i++){  
    scanf("%s %d",Q[i].name,&Q[i].num);
    enqueue(Q[i]);
  }
   
  while(head!=tail){
    if(quantum>=Q[head].num){
      sumtime+=Q[head].num;
      printf("%s %d\n",Q[head].name,sumtime);
      head++;
    }
    else{
      sumtime += quantum;
      Q[head].num -= quantum;
      de = dequeue();
      enqueue(de);
    }
  } 
  return 0;
}
 
int isEmpty(int x,int y){
  if(x == y){
    return TRUE;
  }
  else {
    return FALSE;
     
  }
}
 
int isFULL(int x,int y){
  if(x == (y+1) % M){
    return TRUE;
  }
  else return FALSE;
}
 
void enqueue(Name x){
  if(isFULL(head,tail)==TRUE){
    printf("Over flow!\n");
  }
  Q[tail] = x;
  if(tail + 1 == M){
    tail = 0;
  }
  else
    tail++;
}
 
 
Name dequeue(){
  if(isEmpty(head,tail)==TRUE){
    printf("Under flow!\n");
  }
  Name x;
  x = Q[head];
  if(head + 1 == M){
    head = 0;
  }
  else {
    head++;
  }
  return x; 
}