#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
  int n;
  cin >> n;
  vector<vector<int>> data(3, vector<int>(2));
  for (int i = 0; i < 3; ++i) {
    int temp1, temp2;
    cin >> temp1 >> temp2;
    data[i][0] = temp1;
    data[i][1] = temp2;
  }
  int f = data[0][0], s = data[1][0], t = data[2][0], sum;
  sum = f + s + t;
  while (sum < n) {
    if (f < data[0][1]) {
      ++f;
      ++sum;
    } else {
      if (s < data[1][1]) {
        ++s;
        ++sum;
      } else {
        if (t < data[2][1]) {
          ++t;
          ++sum;
        }
      }
    }
  }
  cout << f << ' ' << s << ' ' << t << '\n';
  return 0;
}
