#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, k, l, m1, n1, m2, n2, m3, n3, n;
  cin >> n;
  int A[3][2], sum = 0;
  for (i = 0; i < 3; i++) {
    cin >> A[i][0] >> A[i][1];
    sum += A[i][0];
  }
  while (sum != n && A[0][0] < A[0][1]) {
    A[0][0]++;
    sum++;
  }
  while (sum != n && A[1][0] < A[1][1]) {
    A[1][0]++;
    sum++;
  }
  while (sum != n && A[2][0] < A[2][1]) {
    A[2][0]++;
    sum++;
  }
  cout << A[0][0] << " " << A[1][0] << " " << A[2][0];
  return (0);
}
