#include <bits/stdc++.h>
using namespace std;
class solution {
 private:
  int max_1, max_2, max_3, min_1, min_2, min_3, n;
  void print_solution(int x, int y, int z) {
    cout << x << " " << y << " " << z << endl;
  }
  int min(int x, int y) {
    if (x < y) {
      return x;
    }
    return y;
  }
  void get_solution() {
    int n1 = min(max_1, n - min_2 - min_3);
    int n2 = min(max_2, n - n1 - min_3);
    int n3 = min(max_3, n - n1 - n2);
    print_solution(n1, n2, n3);
  }

 public:
  solution() {
    cin >> n >> min_1 >> max_1 >> min_2 >> max_2 >> min_3 >> max_3;
    get_solution();
  }
};
int main() {
  solution *obj = new solution();
  return 0;
}
