#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef pair< int , int > Pi;
int dx[] = {1,0,-1,0} , dy[] = {0,1,0,-1};
int main(){
  int tmp[] = {10,50,100,500},n;
  bool ok = false;
  while(cin >> n && n){
    if(ok) cout << endl;
    ok = true;
    int a[4],b[4]={};
    for(int i=0;i<4;i++){
      cin >> a[i];
    }
    int money = (a[3] * 500 + a[2] * 100 + a[1] * 50 + a[0] * 10) - n;
    for(int i=3;i>=0;i--){
      while(money >= tmp[i]){
        money -= tmp[i];
        b[i]++;
      }
    }
    for(int i=0;i<4;i++){
      if(a[i] - b[i] > 0){
        cout << tmp[i] << " " << a[i] - b[i] << endl;
      }
    }
  }
}