#include<stdio.h>
int main(){
    while(1){
        int n,a,b,c,d,r,aa,bb,cc,dd;
        scanf("%d",&n);
        if(n==0) return 0;
        scanf("%d %d %d %d",&a,&b,&c,&d);
        r=10*a+50*b+100*c+500*d-n;
        aa=a-(r%50)/10;
        bb=b-(r%100-10*aa)/50;
        cc=c-(r%500)/100;
        dd=d-r/500;
        if(aa>0) printf("10 %d\n",aa);
        if(bb>0) printf("50 %d\n",bb);
        if(cc>0) printf("100 %d\n",cc);
        if(dd>0) printf("500 %d\n",dd);
        printf("\n");
    }
}