#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define MOD 1000000007

int main(void){
    ll n;
    bool f = false;
    while(1){
        cin >> n;
        if(!n) break;
        n /= 10;
        int c1,c5,c10,c50;
        cin >> c1 >> c5 >> c10 >> c50;
        int b1,b5,b10,b50;
        ll c = c1 + c5*5 + c10*10 + c50*50 - n;
        b50 = max(0LL,c50-c/50);
        c%=50;
        b10 = max(0LL,c10-c/10);
        c%=10;
        b5 = max(0LL,c5-c/5);
        c%=5;
        b1 = max(0LL,c1-c);
        if(f) cout << endl;
        if(b1) cout << "10 " << b1 << endl;
        if(b5) cout << "50 " << b5 << endl; 
        if(b10) cout << "100 " << b10 << endl; 
        if(b50) cout << "500 " << b50 << endl; 
        f = true;
    }
}
