#include <bits/stdc++.h>
using namespace std;
const int N = 333;
int main() {
  int n, a1, a2, a3, b1, b2, b3;
  cin >> n >> a1 >> b1 >> a2 >> b2 >> a3 >> b3;
  int c1 = b1, c2 = b2, c3 = b3;
  while (c1 + c2 + c3 > n) {
    if (c3 > a3)
      c3--;
    else if (c2 > a2)
      c2--;
    else if (c1 > a1)
      c1--;
  }
  cout << c1 << " " << c2 << " " << c3 << endl;
  return 0;
}
