#include <bits/stdc++.h>
using namespace std;
int n, a[4], b[4];
int main() {
  cin >> n;
  for (int i = 1; i < 4; ++i) cin >> a[i] >> b[i], n -= a[i], b[i] -= a[i];
  for (int i = 1; i < 4; ++i)
    cout << a[i] + min(b[i], n) << " ", n -= min(b[i], n);
  cout << "\n";
  return 0;
}
