#include <bits/stdc++.h>
using namespace std;
int maxn[100010], minn[100010];
char s[100010];
int sum;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i <= 2; i++) {
    cin >> minn[i] >> maxn[i];
    sum = sum + minn[i];
  }
  while (sum < n) {
    if (maxn[0] > minn[0]) {
      minn[0]++;
      sum++;
    } else if (maxn[1] > minn[1]) {
      minn[1]++;
      sum++;
    } else if (maxn[2] > minn[2]) {
      minn[2]++;
      sum++;
    }
  }
  printf("%d %d %d", minn[0], minn[1], minn[2]);
}
