#include <bits/stdc++.h>
using namespace std;
int max1, max2, max3, min1, min2, min3;
int main() {
  int n, t1, t2, t3, k;
  while (~scanf("%d", &n)) {
    t1 = 0;
    t2 = 0;
    scanf("%d%d", &min1, &max1);
    scanf("%d%d", &min2, &max2);
    scanf("%d%d", &min3, &max3);
    k = n - min2 - min3;
    if (max1 + max2 + max3 == n)
      printf("%d %d %d\n", max1, max2, max3);
    else if (min1 + min2 + min3 == n)
      printf("%d %d %d\n", min1, min2, min3);
    else if (max1 <= k) {
      t1 = max1;
      k = n - min3 - t1;
      if (max2 <= k) {
        t2 = max2;
        t3 = n - t1 - t2;
        printf("%d %d %d\n", t1, t2, t3);
      } else {
        t2 = k;
        t3 = n - t1 - t2;
        printf("%d %d %d\n", t1, t2, t3);
      }
    } else {
      t1 = k;
      k = n - min3 - t1;
      if (max2 <= k) {
        t2 = max2;
        t3 = n - t1 - t2;
        printf("%d %d %d\n", t1, t2, t3);
      } else {
        t2 = k;
        t3 = n - t2 - t1;
        printf("%d %d %d\n", t1, t2, t3);
      }
    }
  }
  return 0;
}
