#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
constexpr int gcd(int a,int b){return b?gcd(b,a%b):a;}
constexpr int lcm(int a,int b){return a*b/gcd(a,b);}

int main(){
    int n;
    vlai p={10,50,100,500,0};
    while(cin>>n,n){
        vlai c(0,4);
        cin>>c[0]>>c[1]>>c[2]>>c[3];
        int b=(p*c).sum()-n;
        rrep(i,4) while(b>=p[i]){ b-=p[i]; c[i]--;}
        if(p[4]++)cout<<endl;
        rep(i,4){
            if(c[i]>0)cout<<p[i]<<" "<<c[i]<<endl;
        }
    }
}