#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, a1, a2, b1, b2, c1, c2;
  cin >> n >> a1 >> a2 >> b1 >> b2 >> c1 >> c2;
  if (n - b1 - c1 >= 0) {
    if (n - b1 - c1 >= a2) {
      cout << a2 << " ";
      n -= a2;
    } else {
      cout << n - b1 - c1 << " ";
      n = n - (n - b1 - c1);
    }
  }
  if (n - c1 >= 0) {
    if (n - c1 >= b2) {
      cout << b2 << " ";
      n -= b2;
    } else {
      cout << n - c1 << " ";
      n = n - (n - c1);
    }
  }
  cout << n << "\n";
  return 0;
}
