#include <bits/stdc++.h>
using namespace std;
pair<int, int> A[100001];
int main() {
  int n, a, b, c, rem;
  scanf("%d", &n);
  for (int i = 0; i < 3; i++) scanf("%d %d", &A[i].first, &A[i].second);
  c = A[2].first;
  b = A[1].first;
  a = A[0].first;
  rem = n - a - b - c;
  if (rem > 0) {
    a += min(A[0].second - A[0].first, rem);
    rem = rem - min(A[0].second - A[0].first, rem);
  }
  if (rem > 0) {
    b += min(A[1].second - A[1].first, rem);
    rem = rem - min(A[1].second - A[1].first, rem);
  }
  if (rem > 0) {
    c += min(A[2].second - A[2].first, rem);
    rem = rem - min(A[2].second - A[23].first, rem);
  }
  cout << a << " " << b << " " << c << endl;
  return 0;
}
