#include<stdio.h>
#include<stdlib.h>
//#include<string.h>
int main(void){

	int n,q;
	scanf("%d",&n);
	scanf("%d",&q);
	int i,j;
	int p[n];
	for(i=0; i<n; i++){
		printf("p%d ",i+1);
		scanf("%d",&p[i]);
	}

	int queuenum=n-1; 
//	int queue[1000];

	int a[n];
	for(i=0; i<n; i++){
		a[i]=i+1;
	}
	int sec=0;
	int k=0;
	while(k<n){
		if(p[0]-q>0){
			int tmp=p[0]-q;
			int num=a[0];
			for(j=1; j<n; j++){
				p[j-1]=p[j];
				a[j-1]=a[j];
			}
			a[queuenum]=num;
			p[queuenum]=tmp;
		//	printf("上に上がる%d\n",p[queuenum]);
			sec+=100;
		//	printf("処理時間:%d\n",sec);
		}else{
			printf("p%d %d\n",a[0],p[0]+sec,"\n");
			sec+=p[0];
			for(j=1; j<n-k; j++){
				p[j-1]=p[j];
				a[j-1]=a[j];
			}
			k++;
			queuenum--;
		}
	}
	return 0;
}
