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