#include <bits/stdc++.h>
using namespace std;
struct st {
  long long n, v;
  bool operator<(const st &other) const { return v < other.v; }
};
template <typename T>
string ts(T val) {
  std::ostringstream oss;
  oss << val;
  return oss.str();
}
int main() {
  ios_base::sync_with_stdio(0);
  long long n, a, b, a1, b1, a2, b2, k1, k2, k3;
  cin >> n >> a >> b >> a1 >> b1 >> a2 >> b2;
  k1 = a;
  k2 = a1;
  k3 = a2;
  while (k1 + k2 + k3 < n && k1 < b) k1++;
  while (k1 + k2 + k3 < n && k2 < b1) k2++;
  while (k1 + k2 + k3 < n && k3 < b2) k3++;
  cout << k1 << ' ' << k2 << ' ' << k3;
}
