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