#include <bits/stdc++.h>
using namespace std;
void setup() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.precision(15);
}
int main() {
  setup();
  int n;
  cin >> n;
  int f_min, f_max, s_min, s_max, t_min, t_max;
  cin >> f_min >> f_max >> s_min >> s_max >> t_min >> t_max;
  int curr = f_min + s_min + t_min;
  if (curr <= n) {
    int prev = f_min;
    f_min += min(n - curr, f_max - f_min);
    curr += f_min - prev;
  }
  if (curr <= n) {
    int prev = s_min;
    s_min += min(n - curr, s_max - s_min);
    curr += s_min - prev;
  }
  if (curr <= n) {
    t_min += n - curr;
  }
  cout << f_min << " " << s_min << " " << t_min;
  return 0;
}
