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