#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<vector<int>> range(3, vector<int>(2));
  int totalMin = 0;
  for (int i = 0; i < 3; ++i) {
    int temp1, temp2;
    cin >> temp1 >> temp2;
    range[i][0] = temp1;
    range[i][1] = temp2;
    totalMin += temp1;
  }
  if (totalMin == n) {
    cout << range[0][0] << " " << range[1][0] << " " << range[2][0] << '\n';
  } else {
    int a = range[0][0], b = range[1][0], c = range[2][0];
    vector<int> ans(3);
    ans[0] = range[0][0];
    ans[1] = range[1][0];
    ans[2] = range[2][0];
    int left = n - totalMin;
    for (int i = 0; i < 3; ++i) {
      while (left > 0 && range[i][1] > ans[i]) {
        --left;
        ++ans[i];
      }
      if (!left) {
        break;
      }
    }
    cout << ans[0] << " " << ans[1] << " " << ans[2] << '\n';
  }
  return 0;
}
