#include <bits/stdc++.h>
using namespace std;
int N;
int min1, max1, min2, max2, min3, max3;
int res1, res2, res3;
int main() {
  scanf("%d", &N);
  scanf("%d%d", &min1, &max1);
  scanf("%d%d", &min2, &max2);
  scanf("%d%d", &min3, &max3);
  res3 = min(max(N - max1 - max2, min3), max3);
  N -= res3;
  res2 = min(max(N - max1, min2), max2);
  N -= res2;
  res1 = N;
  printf("%d %d %d", res1, res2, res3);
  return 0;
}
