#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int mi[4], mx[4], res[4] = {0};
  for (int i = 0; i < 3; i++) {
    cin >> mi[i] >> mx[i];
    res[i] = mi[i];
    n -= res[i];
  }
  int i = 0;
  while (n) {
    if (res[i] >= mx[i]) {
      i++;
      continue;
    }
    res[i]++;
    n--;
  }
  for (int i = 0; i < 3; i++) cout << res[i] << " ";
  return 0;
}
