#include <stdio.h>
int main(void)
{
    int x, y[]={10, 50, 100, 500};
    while (scanf("%d", &x), x) {
        int a, b, c, d, h, i, j, k, n, res[4]={0};
        scanf("%d%d%d%d", &a, &b, &c, &d);

        n=a+b+c+d;
        for(h=0;h<=a;++h) for(i=0;i<=b;++i)
        for(j=0;j<=c;++j) for(k=0;k<=d;++k) {
            int s=10*h+50*i+100*j+500*k;
            if (s>=x) {
                int m=(a+b+c+d)-(h+i+j+k);
                int p=s-x;
                int a2, b2, c2, d2;
                d2=p/500; p%=500;
                c2=p/100; p%=100;
                b2=p/50; p%=50;
                a2=p/10;
                m+=a2+b2+c2+d2;
                if (n>m) {
                    res[0]=h;
                    res[1]=i;
                    res[2]=j;
                    res[3]=k;
                    n=m;
                }
            }
        }
        for(i=0;i<4;++i) if (res[i]) printf("%d %d\n", y[i], res[i]);
        puts("");
    }
    return 0;
}