#include <bits/stdc++.h>   using namespace std;   int main() {     int num, a1, a2, b1, b2, c1, c2, d, a, b, c;     cin >> num >> a1 >> a2 >> b1 >> b2 >> c1 >> c2;     a = a2;     b = b2;     c = c2;     if (a + b + c == num)       cout << a <<     << b <<     << c;     else {       d = a + b + c - num;       if (c - d >= c1) {         c = c - d;         d = 0;       } else {         d = d - c + c1;         c = c1;       }       if (d > 0)         if (b - d >= b1) {           b = b - d;           d = 0;         } else {           d = d - b + b1;           b = b1;         }       if (d > 0)         if (a - d >= a1) {           a = a - d;           d = 0;         } else {           d = d - a + a1;           a = a1;         }       cout << a <<     << b <<     << c;     }   }   