#include <stdio.h>
int main(void){
    int n,i,c[4],tmp,f=0;
    const int v[]={10,50,100,500};
    while(1){
        if(f)
            puts("");
        scanf("%d",&n);
        if(n==0)
            break;
        tmp=0;
        for(i=0;i<4;i++){
            scanf("%d",&c[i]);
            tmp+=c[i];
        }
        for(i=3;i>=0;i--){
            c[i]-=tmp/v[i];
            tmp%=v[i];
        }
        for(i=0;i<4;i++){
            if(c[i])
                printf("%d %d\n",v[i],c[i]);
        }
        f=1;
    }
}