#include<cstdio>
#include<algorithm>
#include<cstring>


using namespace std;
int n;
int d[4];
int u[4],ru[4];
int mo[4]={10,50,100,500};
int res;


void check(int v){
	if(v==4){
		int coin=0,nowm=0;
		for(int i=0;i<4;i++){
			nowm+=u[i]*mo[i];
			coin+=(d[i]-u[i]);
		}
		nowm-=n;
		if(nowm<0)return;
		int j=3;
		while(nowm>0){
			while(nowm<mo[j])j--;
			if(u[j]>0)return;
			nowm-=mo[j];
			coin++;
		}
		if(res>coin){
			res=coin;
			for(int i=0;i<=3;i++){
				ru[i]=u[i];
			}
		}
	}else{
		for(int i=0;i<=d[v];i++){
			u[v]=i;
			check(v+1);
			u[v]=0;
		}
	}
}

int main(void){
	int ddd=0;
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		if(ddd!=0){
			printf("\n");
		}else ddd++;
		for(int i=0;i<4;i++){
			scanf("%d",&d[i]);
		}
		res=114514;
		check(0);
		for(int i=0;i<=3;i++){
			if(ru[i]>0){
				printf("%d %d\n",mo[i],ru[i]);
			}
		}
	}
	return 0;
}