#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int coin[]={10,50,100,500};
int main(){
	int a[4],b[4],k,c,s=1;
	while(cin>>c,c){
		if(s!=1)cout<<endl;
		s=-c;
		rep(i,4)cin>>b[i],s+=b[i]*coin[i],a[i]=0;
		rep(i,4)while(s>=coin[3-i])s-=coin[3-i],a[3-i]++;
		rep(i,4){
			k=b[i]-a[i];if(k>0)cout<<coin[i]<<" "<<k<<endl;
		}
	}
	return 0;
}