#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define all(a) (a).begin(), (a).end()

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
	int n; int q = 0;
	while(cin >> n, n){
		if(q != 0) cout << endl;
		int p[4] = {10, 50, 100, 500};
		int c[4];
		vector<int> ret(4);
		int sum = 0;
		rep(i, 4){ cin >> c[i]; sum += c[i]*p[i];}
		sum -= n;
		for(int i = 3; 0 <= i; i--){ret[i] = sum/p[i]; sum %= p[i];}
		for(int i=0; i < 4; i++){
			if(c[i]-ret[i] > 0) cout << p[i] << " " << c[i]-ret[i] << endl;
		}
		q++;
	}
}