#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d, e, f, n;
  cin >> n;
  cin >> a >> b >> c >> d >> e >> f;
  int g = n - c - e;
  if (b >= g) {
    cout << g << " " << c << " " << e << endl;
  } else {
    int k = g - b;
    k = k + c;
    if (k <= d) {
      cout << b << " " << k << " " << e << endl;
    } else {
      int i = k - d;
      i = i + e;
      cout << b << " " << d << " " << i << endl;
    }
  }
  return 0;
}
