#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, n, j, m[5][2];
  cin >> n;
  for (i = 1; i <= 3; i++)
    for (j = 0; j <= 1; j++) cin >> m[i][j];
  int a[4], sum;
  a[1] = m[1][0];
  a[2] = m[2][0];
  a[3] = m[3][0];
  sum = a[1] + a[2] + a[3];
  for (i = 1; i <= 3; i++) {
    while (sum < n && a[i] < m[i][1]) {
      sum++;
      a[i]++;
    }
  }
  cout << a[1] << " " << a[2] << " " << a[3] << endl;
  return 0;
}
