#include <bits/stdc++.h>
using namespace std;
template <class T>
bool setmax(T &_a, T _b) {
  if (_b > _a) {
    _a = _b;
    return true;
  }
  return false;
}
template <class T>
bool setmin(T &_a, T _b) {
  if (_b < _a) {
    _a = _b;
    return true;
  }
  return false;
}
template <class T>
T gcd(T _a, T _b) {
  return _b == 0 ? _a : gcd(_b, _a % _b);
}
int main() {
  int n, l[3], r[3], v[3];
  scanf("%d", &n);
  for (int i = int(0); i <= int((3) - 1); ++i)
    scanf("%d%d", &l[i], &r[i]), v[i] = l[i], n -= v[i];
  for (int i = int(0); i <= int((3) - 1); ++i) {
    int d = min(r[i] - l[i], n);
    n -= d, v[i] += d;
  }
  for (int i = int(0); i <= int((3) - 1); ++i) printf("%d ", v[i]);
  return 0;
}
