#include <iostream>
using namespace std;
int main()
{
    int c[4], m[4];
    for (int i = 1; i <= 3; i++) {
        cin >> c[i] >> m[i];
    }
    int t = 0, now = 1;
    while (t < 100) {
        int xia = now + 1;
        if (now == 3) {
            xia = 1;
        }
        m[xia] += m[now];
        m[now]=0;
        if (m[xia] > c[xia]) {
            m[now] = m[xia] - c[xia];
            m[xia] = c[xia];
        }
        now = xia;
        t++;/*
        cout << t << endl;
        for (int i = 1; i <= 3; i++) {
            cout << m[i] << endl;
        }
        cout<<endl;*/
    }
    for (int i = 1; i <= 3; i++) {
        cout << m[i] << endl;
    }
}