#include <bits/stdc++.h>
using namespace std;
int main() {
  long int n, a, b, c, d, e, f;
  cin >> n >> a >> b >> c >> d >> e >> f;
  long int sum = c + e;
  long int ans1 = min(n - sum, b);
  n = n - ans1;
  sum = sum - c;
  long int ans2 = min(n - sum, d);
  n = n - ans2;
  cout << ans1 << " " << ans2 << " " << n << endl;
  return 0;
}
