#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int mi[4], mm[4];
  for (int i = 1; i <= 3; i++) {
    scanf("%d%d", &mi[i], &mm[i]);
  }
  n = n - mi[1] - mi[2] - mi[3];
  int x1 = mi[1];
  int x2 = mi[2];
  int x3 = mi[3];
  if (n > 0) {
    mi[1] += min(n, mm[1] - mi[1]);
    n = n + x1 - mm[1];
  }
  if (n > 0) {
    mi[2] += min(n, mm[2] - mi[2]);
    n = n - mm[2] + x2;
  }
  if (n > 0) {
    mi[3] += min(n, mm[3] - mi[3]);
    n = n - mm[3] + x3;
  }
  printf("%d %d %d\n", mi[1], mi[2], mi[3]);
  return 0;
}
