#include <bits/stdc++.h>
using namespace std;
inline int scan() {
  int n = 0, sign = 1, ch = getchar();
  while (ch < 48 || ch > 57) {
    if (ch == '-') {
      sign = -1;
    }
    ch = getchar();
  }
  while (ch >= 48 && ch <= 57) {
    n = (n << 3) + (n << 1) + ch - 48;
    ch = getchar();
  }
  return n * sign;
}
int main() {
  int n, min1, min2, min3, max1, max2, max3, temp, allot1, allot2, allot3;
  n = scan();
  min1 = scan();
  max1 = scan();
  min2 = scan();
  max2 = scan();
  min3 = scan();
  max3 = scan();
  temp = n - min1 - min2 - min3;
  allot1 = min1;
  allot2 = min2;
  allot3 = min3;
  if (min1 + min2 + min3 == n) {
    printf("%d %d %d", min1, min2, min3);
  } else {
    if (temp > max1 - min1) {
      allot1 = max1;
      temp -= max1 - min1;
    } else {
      allot1 += temp;
      temp = 0;
    }
    if (temp == 0) {
      goto l1;
    }
    if (temp > max2 - min2) {
      allot2 = max2;
      temp -= max2 - min2;
    } else {
      allot2 += temp;
      temp = 0;
    }
    if (temp == 0) {
      goto l1;
    }
    if (temp > max3 - min3) {
      allot3 = max3;
      temp -= max3 - min3;
    } else {
      allot3 += temp;
      temp = 0;
    }
  l1:
    printf("%d %d %d", allot1, allot2, allot3);
  }
}
