#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, l[3], r[3], a, b, c;
  scanf("%d", &n);
  for (int i = 0; i < 3; i++) {
    scanf("%d%d", &l[i], &r[i]);
  }
  c = max(n - (r[0] + r[1]), l[2]);
  n -= c;
  b = max(n - r[0], l[1]);
  a = n - b;
  printf("%d %d %d\n", a, b, c);
  return 0;
}
