#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<cmath>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
  int h=1,i;
  int a[4]={10,50,100,500};
  int n;
  while(cin>>n,n){
    int b[4],c[4];
    for(i=0;i<4;++i)
      cin>>b[i];
    copy(b,b+4,c);
    int sm=0;
    for(i=3;i>=0;--i){
      if(sm<n){
	int p=min(c[i],(n-sm)/a[i]+((n-sm)%a[i]?1:0));
	sm+=a[i]*p;
	c[i]-=p;
      }
    }
    sm-=n;
    for(i=3;i>=0;--i){
      c[i]+=sm/a[i];
      sm-=sm/a[i]*a[i];
    }
    for(i=0;i<3;++i){
      c[i+1]+=c[i]/(a[i+1]/a[i]);
      c[i]-=c[i]/(a[i+1]/a[i])*(a[i+1]/a[i]);
    }
    if(h)
      h=0;
    else
      cout<<endl;  
    for(i=0;i<4;++i){
      if(b[i]>c[i])
	cout<<a[i]<<" "<<b[i]-c[i]<<endl;
    }
  }
  return 0;
}