#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

ll a[4];
ll b[4];
ll c[5]={10,50,100,500,1000000000};
_;
int main(){
	ll n;
	while(scanf("%lld",&n),n){
		if(_++)puts("");
		rep(i,0,4)scanf("%lld",a+i);
		ll s=-n;
		rep(i,0,4)s+=a[i]*c[i];
		for(int i=3;i>=0;i--)b[i]=s%c[i+1]/c[i];
		rep(i,0,4)if(b[i]<a[i])printf("%lld %lld\n",c[i],a[i]-b[i]);
	}
}


