#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int n;
int c[] = {10,50,100,500};
int k[4];
int a[4];
int main(void){
  bool f = false;
  while(cin >> n){
    if(!n) break;
    if(f) cout << endl;
    f = true;
    memset(a,0,sizeof(a));
    int sum = 0;
    for(int i = 0; i < 4; i++){
      cin >> k[i];
      sum += k[i]*c[i];
    }

    sum -= n;
    for(int i = 3; i >= 0; i--){
      a[i] += sum/c[i];
      sum %= c[i];
    }

    for(int i = 0; i < 4; i++){
      if(max(0,k[i] - a[i])){
	cout << c[i] << " " << max(0,k[i] - a[i]) << endl;
      }
    }
  }
}