#include <bits/stdc++.h>
using namespace std;
int n;
int mn[3];
int mx[3];
int main() {
  cin >> n;
  for (int i = 0; i < 3; i++) {
    cin >> mn[i] >> mx[i];
    n -= mn[i];
  }
  for (int i = 0; i < 3; i++) {
    if (n >= mx[i] - mn[i]) {
      n += mn[i];
      mn[i] = mx[i];
      n -= mx[i];
    } else {
      mn[i] += n;
      n = 0;
    }
    cout << mn[i] << " ";
  }
  cout << endl;
  return 0;
}
