#include using namespace std; typedef long long ll; ll d[102][102][102][102]; int main() { int v[4]; for(int i = 0; i < 4; i++) { cin >> v[i]; } ll n; cin >> n; int a[4]{0}; a[0] = v[0]; int i = 0; while(true) { if(d[a[0]][a[1]][a[2]][a[3]]) { n %= (d[a[0]][a[1]][a[2]][a[3]] - n); } else { d[a[0]][a[1]][a[2]][a[3]] = n; } if(!n) break; int k = min(a[i], v[(i + 1) % 4] - a[(i + 1) % 4]); a[i] -= k; a[(i + 1) % 4] += k; i = (i + 1) % 4; n--; } for(int i = 0; i < 4; i++) { cout << a[i] << " "; } cout << endl; }