#include <bits/stdc++.h>
using namespace std;
int main() {
  int x[3], y[3];
  int n;
  scanf("%d", &n);
  for (int i = (0); i < (3); ++i) scanf("%d %d", &x[i], &y[i]);
  int prvi = 0;
  for (int p = y[0]; p >= x[0]; --p) {
    if (p + x[1] + x[2] > n) continue;
    prvi = p;
    while (p + x[1] + x[2] != n) {
      if (x[1] != y[1])
        x[1]++;
      else if (x[2] != y[2])
        x[2]++;
    }
    printf("%d %d %d\n", p, x[1], x[2]);
    exit(0);
  }
  return 0;
}
