#include using namespace std; #ifdef _RUTHEN #include "debug.hpp" #else #define show(...) true #endif using ll = long long; #define rep(i, n) for (int i = 0; i < (n); i++) template using V = vector; int main() { ios::sync_with_stdio(false); cin.tie(0); V a(4); for (int i = 0; i < 4; i++) cin >> a[i]; ll N; cin >> N; if (N <= 10000000) { V b = {a[0], 0, 0, 0}; rep(i, N) { int from = (i + 1 + 3) % 4, to = (i + 1) % 4; int t = min(b[from], a[to] - b[to]); b[from] -= t; b[to] += t; } cout << b[0] << ' ' << b[1] << ' ' << b[2] << ' ' << b[3] << '\n'; return 0; } map, int> mp; V b = {a[0], 0, 0, 0}; mp[b] = 0; int cnt = 1; while (true) { int from = (cnt + 3) % 4, to = cnt % 4; int t = min(b[from], a[to] - b[to]); b[from] -= t; b[to] += t; show(b); if (cnt == N) { cout << b[0] << ' ' << b[1] << ' ' << b[2] << ' ' << b[3] << '\n'; return 0; } if (mp.count(b)) { int cy = cnt - mp[b]; show(cy); N -= mp[b]; N %= cy; for (auto& [bb, c] : mp) { if (c == N + mp[b]) { cout << bb[0] << ' ' << bb[1] << ' ' << bb[2] << ' ' << bb[3] << '\n'; return 0; } } } else { mp[b] = cnt++; } } return 0; }