#include <bits/stdc++.h>
using namespace std;
long n, m;
long a[4], b[4], c[4];
int main() {
  cin >> n;
  for (int i = 1; i <= 3; i++) {
    cin >> a[i] >> b[i];
    c[i] = a[i];
  }
  m = a[1] + a[2] + a[3];
  for (int i = 1; i <= 3; i++) {
    while (c[i] < b[i] && m < n) {
      c[i] += 1;
      m += 1;
    }
  }
  cout << c[1] << " " << c[2] << " " << c[3];
  return 0;
}
