#include <bits/stdc++.h>
using namespace std;
int main() {
  long int n, min1, min2, min3, max1, max2, max3;
  cin >> n;
  cin >> min1;
  cin >> max1;
  cin >> min2;
  cin >> max2;
  cin >> min3;
  cin >> max3;
  int pri = min1, se = min2, ter = min3;
  if ((pri + se + ter) == n) {
    cout << pri << " " << se << " " << ter;
  } else {
    while (pri + se + ter != n) {
      if (pri < max1) {
        pri++;
      } else {
        if (se < max2) {
          se++;
        } else {
          if (ter < max3) {
            ter++;
          }
        }
      }
    }
    cout << pri << " " << se << " " << ter;
  }
  return 0;
}
