#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n, mn1, mn2, mn3, mx1, mx2, mx3;
  cin >> n >> mn1 >> mx1 >> mn2 >> mx2 >> mn3 >> mx3;
  int ans1 = mn1, ans2 = mn2, ans3 = mn3, tmp = n - mn1 - mn2 - mn3;
  if (tmp > 0) {
    if (mx1 - mn1 > tmp) {
      ans1 += tmp;
      tmp = 0;
    } else {
      ans1 = mx1;
      tmp -= (mx1 - mn1);
    }
  }
  if (tmp > 0) {
    if (mx2 - mn2 > tmp) {
      ans2 += tmp;
      tmp = 0;
    } else {
      ans2 = mx2;
      tmp -= (mx2 - mn2);
    }
  }
  if (tmp > 0) {
    if (mx3 - mn3 > tmp) {
      ans3 += tmp;
      tmp = 0;
    } else {
      ans3 = mx3;
      tmp -= (mx3 - mn3);
    }
  }
  cout << ans1 << " " << ans2 << " " << ans3;
}
