#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int mi1, ma1, mi3, ma3, mi2, ma2;
  cin >> mi1 >> ma1;
  cin >> mi2 >> ma2;
  cin >> mi3 >> ma3;
  long long int a = n - (mi1 + mi2 + mi3);
  if (a > (ma1 - mi1)) {
    cout << ma1;
    a -= ma1 - mi1;
  } else {
    cout << mi1 + a;
    a = 0;
  }
  cout << " ";
  if (a > (ma2 - mi2)) {
    cout << ma2;
    a -= ma2 - mi2;
  } else {
    cout << mi2 + a;
    a = 0;
  }
  cout << " ";
  if (a > (ma3 - mi3)) {
    cout << ma3;
    a -= ma3 - mi3;
  } else {
    cout << mi3 + a;
    a = 0;
  }
  return 0;
}
