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