#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
int a;
int main()
{
	cin>>a;
	while(a)
	{
		int c[4]={},ans[4],m=1e9;
		for(int i=0;i<4;i++)cin>>c[i];
		for(int i=0;i<=c[0];i++)for(int j=0;j<=c[1];j++)for(int k=0;k<=c[2];k++)for(int l=0;l<=c[3];l++)
		{
			int ret=i*10+j*50+k*100+l*500;
			ret=a-ret;
			if(ret>0)continue;
			ret*=-1;
			int now=c[0]-i+c[1]-j+c[2]-k+c[3]-l;
			now+=ret/500;
			ret%=500;
			now+=ret/100;
			ret%=100;
			now+=ret/50;
			ret%=50;
			now+=ret;
			if(m>now)
			{
				ans[0]=i,ans[1]=j,ans[2]=k,ans[3]=l;
				m=now;
			}
		}
		for(int i=0;i<4;i++)
		{
			if(!ans[i])continue;
			cout<<(i==3?"500 ":i==2?"100 ":i==1?"50 ":"10 ")<<ans[i]<<endl;
		}
		cin>>a;
		if(a)cout<<endl;
	}
}
