#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int min1, min2, min3;
  int max1, max2, max3;
  int a, b, c;
  cin >> min1 >> max1 >> min2 >> max2 >> min3 >> max3;
  int left = n - min1 - min2 - min3;
  a = min1;
  b = min2;
  c = min3;
  if (left > 0) {
    if (left <= max1 - min1) {
      a = a + left;
    } else {
      a = a + max1 - min1;
      left = left - max1 + min1;
      if (left <= max2 - min2) {
        b += left;
      } else {
        b += max2 - min2;
        left = left - max2 + min2;
        if (left <= max3 - min3) {
          c += left;
        } else {
          c += max3 - min3;
        }
      }
    }
  }
  cout << a << " " << b << " " << c;
  return 0;
}
