#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, maxf, minf, maxs, mins, maxt, mint;
  cin >> n;
  cin >> minf >> maxf;
  cin >> mins >> maxs;
  cin >> mint >> maxt;
  int givenf, givens, givent;
  if (maxf + mins + mint > n) {
    givenf = n - mins - mint;
  } else {
    givenf = min(maxf, n);
  }
  if (maxs + mint > n - givenf) {
    givens = n - givenf - mint;
  } else {
    givens = min(maxs, n - givenf);
  }
  givent = n - givenf - givens;
  cout << givenf << " " << givens << " " << givent;
  return 0;
}
