#include <bits/stdc++.h>
using namespace std;
queue<pair<int, int> > q;
vector<int> vec;
int num;
int main() {
  int n, min1, max1, min2, max2, min3, max3;
  int one, two, th;
  cin >> n >> min1 >> max1 >> min2 >> max2 >> min3 >> max3;
  int left = n - min2 - min3;
  if (max1 >= left) {
    one = left;
    two = min2;
    th = min3;
  } else {
    left -= max1;
    if (max2 - min2 >= left) {
      one = max1;
      two = left + min2;
      th = min3;
    } else {
      left += min2;
      left -= max2;
      one = max1;
      two = max2;
      th = left + min3;
    }
  }
  cout << one << " " << two << " " << th;
}
