#include <stdio.h>

int main() {
  int amount, X, L, C, D ,n;
  while (scanf("%d", &amount), amount != 0) {
    int Xo = 0, Lo = 0, Co = 0, Do = 0;
    scanf("%d%d%d%d", &X, &L, &C, &D);
    if (X >= (n = amount%50/10)) {
      X -= n, Xo += n, amount -= n * 10;
      for (; amount >= 50 && X >= 5; X -= 5, Xo += 5, amount -= 50);
      for (; amount >= 100 && X >= 10; X -= 10, Xo += 10, amount -= 100);
    }
    else
      amount -= n * 10 + 50;
    if (L >= (n = amount%100/50)) {
      L -= n, Lo += n, amount -= n * 50;
      for (; amount >= 100 && L >= 2; L -= 2, Lo += 2, amount -= 100);
      for (; amount >= 500 && L >= 10; L -= 10, Lo += 10, amount -= 500);
    }
    else
      amount -= n * 50 + 100;
    if (C >= (n = amount%500/100)) {
      C -= n, Co += n, amount -= n * 100;
      for (; amount >= 500 && C >= 5; C -= 5, Co += 5, amount -= 500);
    }
    else
      amount -= n * 100 + 500;
    Do = amount/500;
    if (Xo > 0)
      printf("10 %d\n", Xo);
    if (Lo > 0)
      printf("50 %d\n", Lo);
    if (Co > 0)
      printf("100 %d\n", Co);
    if (Do > 0)
      printf("500 %d\n", Do);
    printf("\n");
  }
}