#include<stdio.h>
#define m(a,b) (a<b?a:b)
int n[5],i,v[5]={0,10,50,100,500},t;
int main()
{
	for(;scanf("%d",&n[i++%5]),n[0];)
	if(i%5==0)
	{
		int u[5]={0};
		for(i=5;--i;)
			if(n[i])
			{
				u[i]+=m(n[0]/v[i],n[i]);
				n[i]-=u[i];
				n[0]-=v[i]*u[i];
			}
		for(i=1;i<5;i++)
			if(n[i]&&n[0]>=0)
			{
				t=m((n[0]/v[i]+(n[0]%v[i])?1:0),n[i]);
				n[i]-=t;
				n[0]-=v[i]*t;
				u[i]+=t;
			}
		for(i=1;i<5;i++)
			u[i]?printf("%d %d\n",v[i],u[i]):0;
		puts("");
	}
	return 0;
}