#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, mn1, mx1, mn2, mx2, mn3, mx3;
  scanf("%d%d%d%d%d%d%d", &n, &mn1, &mx1, &mn2, &mx2, &mn3, &mx3);
  int a1, a2;
  a1 = min(n - mn2 - mn3, mx1);
  a2 = min(n - a1 - mn3, mx2);
  printf("%d %d %d\n", a1, a2, n - a1 - a2);
  return 0;
}
