#include <stdio.h>
int main(void)
{
    int f=0, x, y[]={10, 50, 100, 500};
    while (scanf("%d", &x)) {
        int c[4], i, k[4], n, res[4]={0};
        if (!x) break;
        if (f) puts("");
        f=1;
        for(n=i=0;i<4;++i) scanf("%d", c+i);
        n=1<<30;
#define REP(x) for(k[x]=0;k[x]<=c[x];++k[x])
        REP(0) REP(1) REP(2) REP(3) {
            int s=0;
            for(i=0;i<4;++i) s+=y[i]*k[i];
            if (s>=x) {
                int m=0;
                int p=s-x;
                int c2[4]={0};
                int ok=1;
                for(i=3;i>=0;--i) {
                    c2[i]=p/y[i];
                    p%=y[i];
                    if (c2[i] && k[i]) ok=0;
                    m+=c[i]-k[i]+c2[i];
                }
                if (n>m && ok) {
                    for(i=0;i<4;++i) res[i]=k[i];
                    n=m;
                }
            }
        }
        for(i=0;i<4;++i) if (res[i]) printf("%d %d\n", y[i], res[i]);
    }
    return 0;
}