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