#include <bits/stdc++.h>
using namespace std;
class Task {
 private:
  int n, a, b, c, d, e, f;
  long freq[5];

 public:
  void exe() {
    cin >> n >> a >> b >> c >> d >> e >> f;
    freq[1] = a;
    freq[2] = c;
    freq[3] = e;
    n = n - (a + c + e);
    a = b - a;
    c = d - c;
    e = f - e;
    if (n) {
      if (a <= n)
        freq[1] += a, n -= a;
      else
        freq[1] += n, n = 0;
    }
    if (n) {
      if (c <= n)
        freq[2] += c, n -= c;
      else
        freq[2] += n, n = 0;
    }
    if (n) {
      if (e <= n)
        freq[3] += e, n -= e;
      else
        freq[3] += n, n = 0;
    }
    for (int i = (int)(1); i <= (int)(3); ++i) cout << freq[i] << " ";
  }
};
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  Task Solver;
  Solver.exe();
  return 0;
}
