#include <bits/stdc++.h>
using namespace std;
int n, a1, a2, b1, b2, c1, c2, r1, r2, r3;
int main() {
  cin >> n >> a1 >> a2 >> b1 >> b2 >> c1 >> c2;
  n -= a1 + b1 + c1;
  while (n > 0 && a1 < a2) {
    n--;
    a1++;
  }
  while (n > 0 && b1 < b2) {
    n--;
    b1++;
  }
  while (n > 0 && c1 < c2) {
    n--;
    c1++;
  }
  printf("%d %d %d\n", a1, b1, c1);
  return 0;
}
