#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, maxa, mina, maxb, minb, maxc, minc, a = 0, b = 0, c = 0;
  cin >> n >> mina >> maxa >> minb >> maxb >> minc >> maxc;
  c = minc;
  b = minb;
  a = n - c - b;
  if (a > maxa) {
    b += a - maxa;
    a = maxa;
  }
  if (b > maxb) {
    c += b - maxb;
    b = maxb;
  }
  cout << a << " " << b << " " << c;
  return 0;
}
