#include <bits/stdc++.h>
using namespace std;
int n, lb[9], rb[9];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= 3; i++) scanf("%d%d", &lb[i], &rb[i]);
  if (rb[1] + lb[2] + lb[3] <= n) {
    printf("%d ", rb[1]);
    n = n - rb[1];
    if (rb[2] + lb[3] <= n)
      printf("%d %d\n", rb[2], n - rb[2]);
    else
      printf("%d %d\n", n - lb[3], lb[3]);
  } else {
    printf("%d %d %d\n", n - lb[2] - lb[3], lb[2], lb[3]);
  }
  return 0;
}
