#include<iostream>
using namespace std;

int bill,num[4],rtrn[4],coin[4]={10,50,100,500};

int main()
{
	bool first=true;
	while(cin>>bill&&bill!=0)
	{
		if(!first) cout<<endl;
		else first=false;
		int sum=0;
		for(int i=0;i<4;i++)
		{
			cin>>num[i];
			sum=sum+num[i]*coin[i];
			rtrn[i]=0;
		}

		sum-=bill;

		for(int i=3;i>-1;i--)
		{
			while(sum>=coin[i]){sum-=coin[i]; rtrn[i]++;}
		}

		for(int i=0;i<4;i++)
		{
			int x=num[i]-rtrn[i];
			if(x>0) cout<<coin[i]<<" "<<x<<endl;
		}

	}
	return 0;
}