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