#include <bits/stdc++.h>

using namespace std;

int main()
{
	int coins[4] = {10, 50, 100, 500};
	int price;
	bool flag = true;

	while (true){
		scanf("%d", &price);

		if (price == 0){
			break;
		}

		int have_coins[4];
		int sum = 0;

		for (int i = 0; i < 4; i++){
			scanf("%d", &have_coins[i]);

			sum += coins[i] * have_coins[i];
		}

		int exceed = sum - price;

		for (int i = 3; i >= 0; i--){
			have_coins[i] -= exceed / coins[i];
			exceed %= coins[i];
		}

		if (flag){
			flag = false;
		}
		else {
			puts("");
		}

		for (int i = 0; i < 4; i++){
			if (have_coins[i] > 0){
				printf("%d %d\n", coins[i], have_coins[i]);
			}
		}
	}

	return (0);
}