#include <stdio.h>
#include <stdlib.h>
 struct data{
   char name[11];
   int time;
 };

struct data data[100001];
int cal(int);
void deque();
void enqueue();
int confirm1();
int confirm2();
int head=0,tail;
  
int main(){
  int n,q,i,a;
  
  scanf("%d%d",&n,&q);

  tail=n;
  for(i=0;i<n;i++) scanf("%s%d",data[i].name,&data[i].time);

   
  while(head!=tail){

    a=cal(q);
     
     
    if(a==1) deque();
    else enqueue();

     
  }


  return 0;
}

int cal(int q){

  static int time=0;
 
  
  if(data[head].time<=q){ printf("%s %d\n",data[head].name,data[head].time+time);
    time+=data[head].time;
    return 1;
  }

  else {data[head].time=data[head].time-q;
    time+=q;
    return -1;
  }

}

void deque(){
  int a;

  a=confirm1();
  if(a==1){printf("Too Large\n");
    exit(1);
  }
  if(head+1==100000) head=0;
  else head++;
}
void enqueue(){
  int a;

  a=confirm2();
  if(a==1){printf("Empty\n");
    exit(2);
  }
  data[tail]=data[head];
  if(tail+1==100000) tail=0;
  else tail++;
  head++;
}

int confirm1(){

  if(head==(tail+1)%100000) return 1;
  else return -1;
  
}

int confirm2(){
  if(head==tail) return 1;
  else return -1;

}