#include<iostream>
#include<sstream>

using namespace std;

int main(){
	ostringstream out;
	int coin[]={10,50,100,500},c[4];
	int pay,first=0;
	while(cin >> pay, pay){
		if(first++)
			out << endl;
		pay*=-1;
		for(int i=0;i<4;i++){
			cin >> c[i];
			pay+=coin[i]*c[i];
		}
		for(int i=3;i>=0;i--){
			if(pay/coin[i]==0)continue;
			c[i]-=pay/coin[i];
			pay=pay%coin[i];
		}
		for(int i=0;i<4;i++)
			if(c[i]>0)
				out << coin[i] << " " << c[i] << endl;
	}
	cout << out.str();
	return 0;
}