#include <bits/stdc++.h>
using namespace std;
int a[3];
int b[3];
int main() {
  ios::sync_with_stdio(0);
  int n;
  cin >> n;
  for (int i = 0; i < 3; ++i) cin >> a[i] >> b[i];
  int va = min(b[0], n - a[1] - a[2]);
  n -= va;
  int vb = min(b[1], n - a[2]);
  n -= vb;
  cout << va << " " << vb << " " << n << "\n";
  return 0;
}
