#include <bits/stdc++.h>
using namespace std;
int n, mini[3], maxi[3], state[3];
int main() {
  cin >> n;
  for (int i = 0; i < 3; i++) cin >> mini[i] >> maxi[i];
  int remain = n;
  for (int i = 0; i < 3; i++) state[i] = mini[i], remain -= mini[i];
  for (int i = 0; i < 3; i++)
    if (state[i] < maxi[i]) {
      int diff = maxi[i] - state[i];
      int use = min(remain, diff);
      state[i] += use;
      remain -= use;
    }
  cout << state[0] << " " << state[1] << " " << state[2] << endl;
  return 0;
}
