#include<stdio.h>
int main(){
  int m,i,s=-1,c[4],t[4],p[4]={10,50,100,500};
  while(scanf("%d",&m),m){
    if(s>=0)printf("\n");
    for(i=0;i<4;i++)scanf("%d",&c[i]);
    for(i=s=0;i<4;i++)s+=c[i]*p[i];
    s-=m;
    for(i=4;i--;s%=p[i])t[i]=s/p[i];
    for(i=0;i<4;i++)c[i]-=t[i];
    for(i=0;i<4;i++){
      if(c[i]>0)printf("%d  %d\n",p[i],c[i]);
    }
  }
  return 0;
}