#include using namespace std; using ll = unsigned long long; int main(){ vector v(4); vector h(4,0); for(int i = 0;i < 4;++i){ cin >> v[i]; } h[0] = 1LL; h[1] = 10000LL; h[2] = 100000000LL; h[3] = 1000000000000LL; ll n; cin >> n; ll cnt = 0; vector mizu(4); ll now = 0; std::map,ll> pl; mizu[0] = v[0]; pl[make_pair(v[0], 0)] = 0; bool first = false; while(n > 0){ ++cnt; --n; ll ryo = min(mizu[now], v[(now+1)%4]-mizu[(now+1)%4]); mizu[now] -= ryo; mizu[(now+1)%4] += ryo; ll nxt = mizu[0]*h[0] + mizu[1]*h[1] + mizu[2]*h[2] + mizu[3]*h[3]; now += 1; now %= 4; if(pl.count(make_pair(nxt, now)) >= 1 && first == false){ ll pre = pl[make_pair(nxt, now)]; ll kaisu = cnt - pre; ll tmp = n/kaisu; n = n-(kaisu*tmp); first = true; } pl[make_pair(nxt, now)] = cnt; } for(int i = 0;i < 4;++i){ cout << mizu[i] << ' '; } cout << endl; }