#include <bits/stdc++.h>
using namespace std;
int t[3][2];
int main() {
  int n;
  while (cin >> n) {
    int maxi1, mini1, maxi2, mini2, maxi3, mini3;
    scanf("%d%d", &mini1, &maxi1);
    scanf("%d%d", &mini2, &maxi2);
    scanf("%d%d", &mini3, &maxi3);
    vector<int> sol;
    for (int i = maxi1; i >= mini1; i--) {
      if (i <= n) {
        if (mini2 + mini3 <= n - i && n - i <= maxi2 + maxi3) {
          sol.push_back(i);
          n -= i;
          break;
        }
      }
    }
    for (int i = maxi2; i >= mini2; i--) {
      if (i <= n) {
        if (mini3 <= n - i && n - i <= maxi3) {
          sol.push_back(i);
          n -= i;
          break;
        }
      }
    }
    sol.push_back(n);
    for (int i = 0; i < 3; i++) {
      if (i) printf(" ");
      printf("%d", sol[i]);
    }
  }
}
