#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int mi[3];
  int ma[3];
  for (__typeof(3) i = (0) - ((0) > (3)); i != (3) - ((0) > (3));
       i += 1 - 2 * ((0) > (3)))
    cin >> mi[i] >> ma[i];
  int a, b, c;
  a = min(ma[0], n - mi[1] - mi[2]);
  n -= a;
  b = min(ma[1], n - mi[2]);
  n -= b;
  c = n;
  printf("%d %d %d", a, b, c);
  return 0;
}
