#include <bits/stdc++.h>
using namespace std;
void setup() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin.tie(NULL);
  cout.precision(10);
}
int main() {
  setup();
  int n, a = 0, b = 0, c = 0, p, diff;
  int m[3], M[3];
  cin >> n;
  p = n;
  for (int i = 0; i < 3; ++i) {
    cin >> m[i] >> M[i];
  }
  a += m[0];
  p -= a;
  M[0] -= m[0];
  b += m[1];
  p -= b;
  M[1] -= m[1];
  c += m[2];
  p -= c;
  M[2] -= m[2];
  if (p >= M[0]) {
    a += M[0];
    p -= M[0];
  } else {
    a += p;
    p = 0;
  }
  if (p >= M[1]) {
    b += M[1];
    p -= M[1];
  } else {
    b += p;
    p = 0;
  }
  if (p >= M[2]) {
    c += M[2];
    p -= M[2];
  } else {
    c += p;
    p = 0;
  }
  cout << a << " " << b << " " << c;
  return 0;
}
