#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int min[3], max[3];
  int res[3];
  int c = 0;
  for (int i = 0; i < 3; i++) {
    cin >> min[i] >> max[i];
    res[i] = min[i];
    c += min[i];
  }
  int i = 0;
  while (c < n) {
    int t = std::min(max[i] - min[i], n - c);
    res[i] += t;
    c += t;
    i++;
  }
  for (int i = 0; i < 3; i++) cout << res[i] << ' ';
  return 0;
}
