//
//  main.c
//  Make Purse Light
//
//  Created by x15071xx on 2016/06/13.
//  Copyright ?? 2016??´ AIT. All rights reserved.
//

#include <stdio.h>

int judge_pay(int keta,int denom,int coe){
    int b=0;
    if (denom * coe >= keta) {
        b=1;
        return b;
    }
    
    return b;
}

int pay(int keta, int denom){
    int count=0;
    
    count = keta / denom;
    
    return count;
    
}

int main(int argc, const char * argv[]) {
    
    
    while (1) {
        int goukei;
        int i,b=0;
        int ten,five,hand,fivehand;
        int ten_count=0,five_count=0,hand_count=0,fivehand_count=0;
        
        scanf("%d",&goukei);
        
        if (goukei==0) {
            break;
        }
        
        
        scanf("%d %d %d %d",&ten,&five,&hand,&fivehand);
        
        //?¨???? max 13200
        
        // bunnkai
        int keta2=0,keta3=0;
        int goukei_tmp=0;
        goukei_tmp = goukei;
        
        if (goukei >= 100) {
            keta3 = goukei / 100;
            goukei -= keta3 * 100;
            keta3 = keta3 * 100;
        }
        
        if (goukei >= 10) {
            keta2 = goukei / 10;
            goukei -= keta2 * 10;
            keta2 = keta2 * 10;
        }
        //printf("\n%d %d %d %d\n\n",keta5,keta4,keta3,keta2);
        goukei = goukei_tmp;
        //harausyori
        if (keta2 < 50) {
            //10???
            b=judge_pay(keta2,ten,10);
            
            if (b == 1) {
                //haraeru
                //pay
                ten_count += pay(keta2,10);
                ten -= pay(keta2,10);
                goukei -= 10 * pay(keta2,10);
            } else {
                //haraenai
                //50en
                b = judge_pay(keta2, five, 50);
                if (b == 1) {
                    five_count++;
                    five--;
                    goukei -= 50;
                }
            }
        } else if (keta2 >= 50) { // 50 izyou
            b = judge_pay(keta2 - 50, ten, 10);
            if (b == 1) {
                //10enn harau
                ten_count += pay(keta2-50,10);
                ten -= pay(keta2-50,10);
                goukei -= 10* pay(keta2-50,10);
                keta2 -= 10* pay(keta2-50,10);
                //50 haraeru ka miru
                b = judge_pay(keta2, five, 50);
                if (b==1) {
                    //50haraeru
                    five_count++;
                    five--;
                    keta2 -= 50;
                    goukei -= 50;
                }
                if (b==0) {
                    keta3+=100;
                } else if (b==0){
                    keta3+= 100;
                }
            }
        }
        
        //100enn miru
        //500 ??????
        if (keta3 < 500) {
            b = judge_pay(keta3, hand, 100);
            if (b==1) {
                //100haraeru
                hand_count += pay(keta3,100);
                hand -= pay(keta3,100);
                goukei -= 100 * pay(keta3,100);
                //????¨???????
            }else if (b==0) {
                //haraenai
                //500dasu
                b = judge_pay(keta3, fivehand, 500);
                if (b==1) {
                    //haratte syuuryo
                    fivehand_count++;
                    fivehand--;
                    goukei -= 500;
                    //????¨???????
                } else if (b==0) {
                    //50 10 ??¨??????.
                    b = judge_pay(keta3, five, 50);
                    if (b==1) {
                        five_count += pay(keta3,50);
                        five -= pay(keta3,50);
                        goukei -= pay(keta3,50);
                    } else if(b==0){
                        five_count += five;
                        goukei = five * 50;
                        five = 0;
                        
                        b = judge_pay(goukei, ten, 10);
                        if (b==1) {
                            ten_count += pay(keta3,10);
                            goukei = 0;
                        } else if (b==0) {
                            return (-1);
                        }
                    }
                }
            }
        } else if (keta3 >= 500) {
            int waruketa3=keta3/500;
            
            b = judge_pay(keta3 - waruketa3 * 500, hand, 100);
            if (b==1) {
                //100enn bubunn dasu
                hand_count += pay(keta3 - waruketa3 * 500,100);
                ten -= pay(keta3 - waruketa3 * 500,100);
                goukei -= 100*pay(keta3 - waruketa3 * 500,100);
                keta3 -= 100*pay(keta3 - waruketa3 * 500,100);
                
                b = judge_pay(keta3, fivehand, 500);
                if (b==1) {
                    fivehand_count += pay(keta3,500);
                    goukei = 0;
                } else if(b==0){
                    //100 50 10 ??¨??????.
                    b= judge_pay(keta3, hand, 100);
                    if (b==1) {
                        hand_count += pay(keta3,100);
                        hand -= pay(keta3,100);
                        goukei -= pay(keta3,100);
                    } else if (b==0){
                        hand_count += pay(keta3,100);
                        goukei = hand * 100;
                        hand = 0;
                        
                        b = judge_pay(keta3, five, 50);
                        if (b==1) {
                            five_count += pay(keta3,50);
                            five -= pay(keta3,50);
                            goukei -= pay(keta3,50);
                        } else if(b==0){
                            five_count += five;
                            goukei = five * 50;
                            five = 0;
                            
                            b = judge_pay(goukei, ten, 10);
                            if (b==1) {
                                ten_count += pay(keta3,10);
                                goukei = 0;
                            } else if (b==0) {
                                return (-1);
                            }
                        }

                    }
                    
                }
            }
        }
        
        
        
        
        if (goukei <= 0) {
            if (ten_count != 0) {
                printf("10 %d\n",ten_count);
            }
            
            if (five_count != 0) {
                printf("50 %d\n",five_count);
            }
            if (hand_count != 0) {
                printf("100 %d\n",hand_count);
            }
            if (fivehand_count != 0) {
                printf("500 %d\n",fivehand_count);
            }
            printf("\n");
        }
        
    }
    return 0;
}