#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, min1, max1, min2, min3, max2, max3;
  cin >> n >> min1 >> max1 >> min2 >> max2 >> min3 >> max3;
  int first = min1, sec = min2, third = min3;
  int count1 = n - min1 - min2 - min3;
  while (first < max1 && count1 > 0) {
    first++;
    count1--;
  }
  while (sec < max2 && count1 > 0) {
    sec++;
    count1--;
  }
  while (third < max3 && count1 > 0) {
    third++;
    count1--;
  }
  cout << first << " " << sec << " " << third;
}
