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