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