#include <iostream>

using namespace std;

int main() {
	int price;
	int t = 0;
	while ( cin >> price, price ) {
		if (t++) cout << endl;

		int c10, c50, c100, c500; cin >> c10 >> c50 >> c100 >> c500;
		int from = c10 * 10 + c50 * 50 + c100 * 100 + c500 * 500;

		int to = from - price;
		int C500 = to / 500; to -= C500 * 500;
		int C100 = to / 100; to -= C100 * 100;
		int C50 = to / 50; to -= C50 * 50;
		int C10 = to / 10; to -= C10 * 10;

		if (C10 < c10) cout << "10 " << c10-C10 << endl;
		if (C50 < c50) cout << "50 " << c50-C50 << endl;
		if (C100 < c100) cout << "100 " << c100-C100 << endl;
		if (C500 < c500) cout << "500 " << c500-C500 << endl;
	}
}