#include<iostream>
#include<algorithm>
using namespace std;

int main(){
    int n,c[4];
    int sum;
    int en[]={10,50,100,500};
    bool kaigyo=false;
    
    while(1){
        cin>>n;
        if(n==0) break;
        if(kaigyo) cout<<endl;
        kaigyo=true;
        sum=0;
        for(int i=0;i<4;i++){
            cin>>c[i];
            sum+=c[i]*en[i];
        }
        sum-=n;
        for(int i=3;i>=0;i--){
            c[i]-=min(c[i],sum/en[i]);
            sum%=en[i];
        }
        for(int i=0;i<4;i++){
            if(c[i]!=0) cout<<en[i]<<" "<<c[i]<<endl;
        }
    }
}