#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, i, j, k, l, x, y;
  cin >> n;
  long long int mx1, mx2, mx3, mn1, mn2, mn3;
  cin >> mn1 >> mx1;
  cin >> mn2 >> mx2;
  cin >> mn3 >> mx3;
  k = 1e6;
  for (i = 0; i < k; i++) {
    if (mx1 + mx2 + mx3 == n) {
      cout << mx1 << " " << mx2 << " " << mx3 << endl;
      return 0;
    }
    mx3 = max(mn3, mx3 - 1);
  }
  for (i = 0; i < k; i++) {
    if (mx1 + mx2 + mx3 == n) {
      cout << mx1 << " " << mx2 << " " << mx3 << endl;
      return 0;
    }
    mx2 = max(mn2, mx2 - 1);
  }
  for (i = 0; i < k; i++) {
    if (mx1 + mx2 + mx3 == n) {
      cout << mx1 << " " << mx2 << " " << mx3 << endl;
      return 0;
    }
    mx1 = max(mn1, mx1 - 1);
  }
}
