#include <bits/stdc++.h>

using namespace std;

const int units[4] = {10, 50, 100, 500};

int main() {
	int p;
	bool first = true;
	while(cin >> p, p) {
		if(!first) {
			cout << endl;
		}
		first = false;

		int c[4];
		int sum = 0;
		for(int i = 0; i < 4; i++) {cin >> c[i]; sum += units[i]*c[i];}

		sum -= p;
		for(int i = 3; i >= 0; i--) {
			while(sum >= units[i]) {
				sum -= units[i]; c[i]--;
			}
		}

		for(int i = 0; i < 4; i++) {
			if(c[i] > 0)
				cout << units[i] << " " << c[i] << endl;
		}
	}

	return 0;
}