#include <bits/stdc++.h>
using namespace std;
const int coin[] = {10, 50, 100, 500};

int main(void){
  int pay;
  int flg = false;
  while(cin >> pay, pay){
    if(flg) cout << endl;
    flg = true;
    int noc[4];
    int noc_org[4];
    for(int i=0; i < 4; i++){
      int t;
      cin >> t;
      noc[i] = t;
      noc_org[i] = t;
    }
    int charge = (coin[0]*noc[0]+coin[1]*noc[1]+coin[2]*noc[2]+coin[3]*noc[3]) - pay;
    int use[4];
    for(int i=3; i >= 0; i--){
      use[i] = charge / coin[i];
      while(charge >= coin[i]){
        charge -= coin[i];
      }
    }
    for(int i=0; i < 4; i++){
      int out = ((noc_org[i] - use[i] < 0) ? 0 : noc_org[i] - use[i]);
      if(out == 0) continue;
      cout << coin[i] << " " << out << endl;
    }
  }
  return 0;
}