#include <bits/stdc++.h>
using namespace std;
int main() {
  long long i, j, n, a[3][2], res[3], temp = 0;
  cin >> n;
  for (i = 0; i < 3; i++) {
    for (j = 0; j < 2; j++) {
      cin >> a[i][j];
    }
  }
  for (i = 0; i < 3; i++) {
    res[i] = a[i][0];
  }
  for (i = 0; i < 3; i++) {
    temp = res[i] + temp;
  }
  for (i = 0; i < 3; i++) {
    if (temp < n) {
      while (res[i] != a[i][1]) {
        res[i]++;
        temp++;
        if (temp == n) break;
      }
    } else
      break;
  }
  for (i = 0; i < 3; i++) {
    cout << res[i] << " ";
  }
  return 0;
}
