#include <stdio.h>


int main(){

    int flag = 0;
    int c[4],r[4];
    int i,sum,a,money;
    int d[4] = {10,50,100,500};
    while(1){
        scanf("%d",&money);
        if(money == 0){
            break;
        }
        if(flag == 1){
            printf("\n");
        }
        scanf("%d %d %d %d",&c[0],&c[1],&c[2],&c[3]);
        sum = 0;
        for(i = 0; i < 4 ; i++){
            sum += c[i] * d[i];
            r[i] = 0;
        }

        sum = sum - money;
        for(i = 3; i >= 0 ;i--){
           while(sum >= d[i]){
               sum -= d[i];
               r[i]++;
           }
        }

        for(i = 0; i < 4 ; i++){
            a = c[i] - r[i];
            if(a > 0){
                printf("%d %d\n",d[i],a);
            }
        }
    flag = 1;
    }
    return 0;
    
}
