#include<stdio.h>

int main(void){
	int c[]={10,50,100,500};
	int cost,sum;
	int coin[4],d[4];
	int i;
	
	while(1){
		scanf("%d",&cost);
		if(cost==0)return 0;
		fflush(stdin);
		scanf("%d %d %d %d",&coin[0],&coin[1],&coin[2],&coin[3]);
		sum=0;
		for(i=0;i<4;i++){
			sum+=coin[i]*c[i];
		}
		sum-=cost;
		for(i=0;i<4;i++){
			d[i]=0;//ツ渉可甘コツ可サ
		}
		for(i=3;i>=0;i--){
			while(sum>=c[i]){
				sum-=c[i];
				d[i]++;
			}
			if(sum<0)break;
		}
		for(i=0;i<4;i++){
			if(coin[i]-d[i]>0){
				printf("%d %d\n",c[i],coin[i]-d[i]);
			}
		}
		printf("\n");
	}
}