#include <bits/stdc++.h>
using namespace std;
int main() {
  int min1, min2, min3, max1, max2, max3, n;
  int a, b, c;
  cin >> n;
  cin >> min1 >> max1;
  cin >> min2 >> max2;
  cin >> min3 >> max3;
  if (min1 + min2 + min3 == n)
    cout << min1 << " " << min2 << " " << min3;
  else {
    a = min1;
    b = min2;
    c = min3;
    while (a + b + c < n) {
      if (a < max1) {
        if (max1 + b + c <= n)
          a = max1;
        else
          a = n - b - c;
      }
      if (b < max2) {
        if (a + max2 + c <= n)
          b = max2;
        else
          b = n - a - c;
      }
      if (c < max3) {
        if (a + b + max3 <= n)
          c = max3;
        else
          c = n - a - b;
      }
    }
    cout << a << " " << b << " " << c;
  }
}
