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