#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
constexpr int mod = 1e9 + 7;
constexpr int inf = 1e9;
constexpr ll linf = 1e18;
constexpr ld eps = 1e-9;
#define fast_io() ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define fi first
#define se second
#define sz(x) ((int)(x).size())
void solve() {
vector<int> c(3), m(3);
for (int i = 0; i < 3; i++) {
int a, b; cin >> a >> b;
c[i] = a, m[i] = b;
}
int turn = 0;
for (int i = 0; i < 100; i++) {
int can = c[(turn == 2 ? turn - 2 : turn + 1)] - m[(turn == 2 ? turn - 2 : turn + 1)];
can = max({0, min(can, m[turn])});
m[turn] -= can;
m[(turn == 2 ? turn - 2 : turn + 1)] += can;
turn += (turn == 2 ? -2 : 1);
}
for (auto& x : m) cout << x << '\n';
}
int main() {
fast_io();
freopen("mixmilk.in", "r", stdin);
freopen("mixmilk.out", "w", stdout);
int t = 1;
// cin >> t;
while (t--) solve();
return 0;
}
I3ByYWdtYSBHQ0Mgb3B0aW1pemUoIk8zIikKI2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgp1c2luZyBsbCA9IGxvbmcgbG9uZzsKdXNpbmcgbGQgPSBsb25nIGRvdWJsZTsKCmNvbnN0ZXhwciBpbnQgbW9kID0gMWU5ICsgNzsKY29uc3RleHByIGludCBpbmYgPSAxZTk7CmNvbnN0ZXhwciBsbCBsaW5mID0gMWUxODsKY29uc3RleHByIGxkIGVwcyA9IDFlLTk7CgojZGVmaW5lIGZhc3RfaW8oKSBpb3M6OnN5bmNfd2l0aF9zdGRpbyhmYWxzZSk7IGNpbi50aWUobnVsbHB0cik7IGNvdXQudGllKG51bGxwdHIpCiNkZWZpbmUgYWxsKHgpICh4KS5iZWdpbigpLCAoeCkuZW5kKCkKI2RlZmluZSBwYiBwdXNoX2JhY2sKI2RlZmluZ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