#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int n1 = n;
  pair<int, int> a, b, c;
  cin >> a.first >> a.second;
  cin >> b.first >> b.second;
  cin >> c.first >> c.second;
  int x = a.first, y = b.first, z = c.first;
  a.second -= a.first;
  b.second -= b.first;
  c.second -= c.first;
  n1 = n1 - a.first - b.first - c.first;
  while (n1 && a.second) {
    n1--;
    a.second--;
    x++;
  }
  while (n1 && b.second) {
    n1--;
    b.second--;
    y++;
  }
  while (n1 && c.second) {
    n1--;
    c.second--;
    z++;
  }
  cout << x << " " << y << " " << z;
  return 0;
}
