#include<stdio.h>
#define N 100000

typedef struct{
  char name[100];
  int time;
}process;

int initialize();
int isEmpty();
void enqueue(process);
process dequeue();
int min(int,int);

process Q[N];
int head ,tail;

int main(){
  int i;
  int num,quantum;
  int elaps=0,c;
  process variable;

  scanf("%d %d",&num,&quantum);

  for(i=1;i<=num;i++){
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].time);
  }
  head=1;
  tail=num+1;

  while(head!=tail){
    variable=dequeue();
    c=min(quantum,variable.time);
    variable.time-=c;
    elaps+=c;
    if(variable.time>0)enqueue(variable);
    else{
      printf("%s %d\n",variable.name,elaps);
    }
  }

  return 0;
}

int isFull(){
  if(head==(tail+1)%N){
    return 1;
  }else{
    return 0;
  }
}

int isEmpty(){
  if(head==tail){
    return 1;
  }else{
    return 0;
  }
}

void enqueue(process x){
  if(isFull()==1){
    printf("OverFlow\n");
  }else{
    Q[tail]=x;
    if(tail+1==N){
      tail=0;
    }else{
      tail++;
    }
  }
}

process dequeue(){
  process x;

  if(isEmpty()==1){
    printf("Error\n");
  }else{
    x=Q[head];
    if(head+1==N){
      head=0;
    }else{
      head++;
    }
  }
  return x;
}

int min(int a,int b){
  if(a>=b){
    return b;
  }else{
    return a;
  }
}