#include <bits/stdc++.h>
using namespace std;
int main() {
  int m[3] = {0}, ma[3] = {0}, a[3] = {0}, n, j, i;
  cin >> n;
  for (i = 0; i < 3; i++) {
    cin >> m[i] >> ma[i];
    a[i] = m[i];
    n = n - m[i];
  }
  i = 0;
  while (n != 0 && i < 3) {
    if (n > ma[i]) {
      a[i] = ma[i];
      n = n - ma[i] + m[i];
    } else if (m[i] + n > ma[i]) {
      a[i] = ma[i];
      n = n - ma[i] + m[i];
    } else {
      a[i] = a[i] + n;
      n = 0;
    }
    i++;
  }
  for (j = 0; j < 3; j++) cout << a[j] << " ";
}
