#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int coin[] = {10, 50, 100, 500};

int main()
{
    bool first = true;

    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        if(first)
            first = false;
        else
            cout << endl;

        vector<int> a(4);
        int sum = 0;
        for(int i=0; i<4; ++i){
            cin >> a[i];
            sum += a[i] * coin[i];
        }

        sum -= n;
        vector<int> b(4);
        for(int i=3; i>=0; --i){
            b[i] = sum / coin[i];
            sum %= coin[i];
        }

        for(int i=0; i<4; ++i){
            int ret = max(0, a[i] - b[i]);
            if(ret > 0)
                cout << coin[i] << ' ' << ret << endl;
        }
    }
}