#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  pair<int, int> mmx[3];
  for (int i = 0; i < 3; i++) cin >> mmx[i].first >> mmx[i].second;
  int a, b, c;
  a = min(n - mmx[1].first - mmx[2].first, mmx[0].second);
  b = min(n - a - mmx[2].first, mmx[1].second);
  c = n - a - b;
  cout << a << ' ' << b << ' ' << c;
  return 0;
}
