V1,V2,V3,V4,N=map(int,input().split()) def solve(V1,V2,V3,V4,N): V=(V1,V2,V3,V4) s=[V1,0,0,0] st = {tuple(s):0} ts = [tuple(s)] i=0 cnt=0 while N>0: N-=1 cnt+=1 v=s[i] ib=i i+=1 if i>3:i=0 nxt=s[i] c=V[i] d=min(c-nxt,v) s[i]+=d s[ib]-=d t = tuple(s+[i]) if t in st: l=st[t] loop=cnt-l N%=loop s = ts[l+N] break st[t]=cnt ts.append(t[:4]) return s print(*solve(V1,V2,V3,V4,N))