#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int res = 0;
  int ans[3] = {0};
  vector<int> A(3), B(3);
  for (int i = 0; i < 3; i++) {
    cin >> A[i] >> B[i];
    res += A[i];
    ans[i] += A[i];
  }
  for (int i = 0; i < 3; i++) {
    if (res >= n) break;
    for (int j = A[i] + 1; j < B[i] + 1; j++) {
      res++;
      ans[i]++;
      if (res >= n) break;
    }
  }
  for (int i = 0; i < 3; i++) {
    cout << ans[i];
    if (i == 2)
      cout << endl;
    else
      cout << " " << endl;
  }
  return 0;
}
