#include<stdio.h>

int main(void){
  int cost,pay,coin[4],i,tmp[4],money[4]={10,50,100,500};
  while(scanf("%d",&pay)&&pay!=0){
    cost=0;
    for(i=0;i<4;i++) scanf("%d",&coin[i]);
    cost+=10*coin[0]+50*coin[1]+100*coin[2]+500*coin[3];
    tmp[3]=(cost-pay)/500;
    coin[3]-=tmp[3];
    //printf("%d\n",tmp[3]);
    tmp[2]=(cost-pay-500*tmp[3])/100;
    coin[2]-=tmp[2];
    //printf("%d\n",tmp[2]);
    tmp[1]=(cost-pay-500*tmp[3]-100*tmp[2])/50;
    coin[1]-=tmp[1];
    //printf("%d\n",tmp[1]);
    tmp[0]=(cost-pay-500*tmp[3]-100*tmp[2]-50*tmp[1])/10;
    coin[0]-=tmp[0];
    //printf("%d\n",tmp[0]);
    for(i=0;i<4;i++) if(coin[i]>0) printf("%d %d\n",money[i],coin[i]);
  }
  return 0;
}