#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
int main() {
  long long int n, i;
  long long int mn1, mn2, mn3, mx1, mx2, mx3;
  cin >> n >> mn1 >> mx1 >> mn2 >> mx2 >> mn3 >> mx3;
  long long int cnt = n;
  long long int a[5];
  a[1] = mn1;
  cnt -= mn1;
  a[2] = mn2;
  cnt -= mn2;
  a[3] = mn3;
  cnt -= mn3;
  if (cnt > 0) {
    i = mx1 - mn1;
    if (cnt - i >= 0) {
      a[1] += i;
      cnt -= i;
    } else {
      a[1] += cnt;
      cnt = 0;
    }
  }
  if (cnt > 0) {
    i = mx2 - mn2;
    if (cnt - i >= 0) {
      a[2] += i;
      cnt -= i;
    } else {
      a[2] += cnt;
      cnt = 0;
    }
  }
  if (cnt > 0) {
    i = mx3 - mn3;
    if (cnt > i) {
      a[3] += i;
      cnt -= i;
    } else {
      a[3] += cnt;
      cnt = 0;
    }
  }
  cout << a[1] << " " << a[2] << " " << a[3] << endl;
  return 0;
}
