#include <bits/stdc++.h>
using namespace std;
int n, re[3], Min[3], Max[3];
void solve() {
  scanf("%d", &n);
  for (int i = 0; i < 3; i++) {
    scanf("%d %d", &Min[i], &Max[i]);
    re[i] = Min[i];
    n -= re[i];
  }
  for (int i = 0; i < 3 && n; i++) {
    int t = min(n, Max[i] - re[i]);
    re[i] += t;
    n -= t;
  }
  for (int i = 0; i < 3; i++) printf("%d ", re[i]);
}
int main(void) {
  solve();
  return 0;
}
