// #define USE_CPP11
// #define USE_PRINTF

#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <utility>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <complex>
#include <memory>
#include <sstream>

#ifdef USE_CPP11
#include <unordered_map>
#include <unordered_set>
#include <functional>
#endif

#define PRINT(obj) cout << obj << endl
#define REP(i, n) for(int (i) = 0; (i) < (n); i++)
#define SPACE " "

typedef long long ll;

const int INF = 1e9 + 10;

using namespace std;

namespace Scanner {
#ifdef USE_PRINTF
  int    nextInt()    { int    d; scanf("%d" , &d); return d; }
  float  nextFloat()  { float  f; scanf("%f" , &f); return f; }
  double nextDouble() { double f; scanf("%lf", &f); return f; }  
  string nextString() { string s; scanf("%s" , &s); return s; }
  ll     nextll()     { ll     l; scanf("%ll", &l); return l; }
#else
  int    nextInt()    { int    d; cin >> d; return d; }
  float  nextFloat()  { float  f; cin >> f; return f; }
  double nextDouble() { double f; cin >> f; return f; }  
  string nextString() { string s; cin >> s; return s; }
  ll     nextll()     { ll     l; cin >> l; return l; }
#endif

  string getLine() { 
    string input;
    getline(cin, input);
    return input;
  }
};

namespace myLibrary {
  vector<string> split(const string& str, char delim) {
    vector<string> ret;
    size_t current = 0, found;
    while ((found = str.find_first_of(delim, current)) != string::npos) {
      ret.push_back(string(str, current, found - current));
      current = found + 1;
    }
    ret.push_back(string(str, current, str.size() - current));
    return ret;
  }
  
#ifdef USE_CPP11
  ///
  /// higher-order functional
  /// This is something like map in haskell, python, etc.
  /// Sample usage:
  ///   vector<int> a = {1, 2, 3, 4, 5};
  ///   vector<int> b = myLibrary::_Map<int, int>(a, [](int n){
  ///     return n * n;
  ///   });
  /// Result:
  ///   b = 1, 4, 9, 16, 25
  ///
  template<typename T_IN, typename T_OUT, class Functor>
  vector<T_OUT> _Map(vector<T_IN> src, Functor func) {
    vector<T_OUT> ret;
    for (int i = 0; i < src.size(); i++) {
      ret.push_back(func(src[i]));
    }
    return ret;
  }
#endif

};

struct Point {
public:
  int y, x;
  Point(int y, int x): y(y), x(x) { }
  Point() { }
};

/// BEGIN //////////////////////////////////////////////////////////

int main() {
  
  bool flag = false;
  while (true) {
    int n = Scanner::nextInt();
    if (n == 0) {
      break;
    }
    int c10  = Scanner::nextInt();
    int c50  = Scanner::nextInt();
    int c100 = Scanner::nextInt();
    int c500 = Scanner::nextInt();

    int minc = INF;
    int min10, min50, min100, min500;

    REP(i, c10 + 1) {
      REP(j, c50 + 1) {
        REP(k, c100 + 1) {
          REP(l, c500 + 1) {
            int t = 10 * i + 50 * j + 100 * k + 500 * l;
            if (t >= n) {
              int c = 0;
              int u = t - n;
              c += u / 500;
              u %= 500;
              c += u / 100;
              u %= 100;
              c += u / 50;
              u %= 50;
              c += u / 10;
              c += (c10 - i) + (c50 - j) + (c100 - k) + (c500 - l);
              if (c < minc) {
                minc   = c;
                min10  = i;
                min50  = j;
                min100 = k;
                min500 = l; 
              }
            }
          }
        }
      }
    }

    if (flag) {
      printf("\n");
    }
    flag = true;
    if (min10 > 0) {
      printf("10 %d\n", min10);
    }
    if (min50 > 0) {
      printf("50 %d\n", min50);
    }
    if (min100 > 0) {
      printf("100 %d\n", min100);
    }
    if (min500 > 0) {
      printf("500 %d\n", min500);
    }
    
  }
  return 0;
}

/// END   //////////////////////////////////////////////////////////

Measured memory_bytes: 1152