#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, max1, min1, max2, min2, max3, min3, ans1, ans2, ans3;
  cin >> n;
  cin >> min1 >> max1;
  cin >> min2 >> max2;
  cin >> min3 >> max3;
  ans1 = n - (min2 + min3);
  if (ans1 > max1) {
    cout << max1 << " ";
    ans1 = max1;
  } else
    cout << ans1 << " ";
  ans2 = n - (ans1 + min3);
  if (ans2 > max2) {
    cout << max2 << " ";
    ans2 = max2;
  } else
    cout << ans2 << " ";
  ans3 = n - (ans1 + ans2);
  if (ans3 > max3)
    cout << max3;
  else
    cout << ans3;
  return 0;
}
