#include <bits/stdc++.h>
using namespace std;
const int NMAX = (int)1e5;
int N;
int main() {
  cin >> N;
  int m[3], M[3];
  for (int i = 0; i < (int)(3); ++i) cin >> m[i] >> M[i];
  int s = m[0] + m[1] + m[2];
  for (int t = 0; t < 3; ++t)
    while (m[t] < M[t] && s < N) {
      int delta = min(M[t] - m[t], N - s);
      m[t] += delta, s += delta;
    }
  for (int i = 0; i < (int)(3); ++i) cout << m[i] << " ";
  return 0;
}
