#include <bits/stdc++.h>
using namespace std;
int mini[10], maxi[10], dist[10];
int main() {
  int n, i, total;
  scanf("%d", &n);
  total = 0;
  for (i = 0; i < 3; ++i) {
    scanf("%d %d", &mini[i], &maxi[i]);
    total += mini[i];
    dist[i] = mini[i];
  }
  i = 0;
  while (n - total > 0) {
    int available, pot;
    available = maxi[i] - mini[i];
    pot = n - total;
    dist[i] += min(available, pot);
    total += min(available, pot);
    i++;
  }
  for (i = 0; i < 2; ++i) {
    printf("%d ", dist[i]);
  }
  printf("%d\n", dist[2]);
  return 0;
}
