from collections import defaultdict VN = list(map(int,input().split())) V = VN[:4] N = VN[4] dic = defaultdict(int) S = [V[0],0,0,0] X = [tuple(S)] dic[X[0]] = 0 turn = 0 tturn = 0 while tturn < N: turn2 = (turn + 1) % 4 s0 = S[turn] s1 = S[turn2] if s0 + s1 <= V[turn2]: S[turn2] = s0 + s1 S[turn] = 0 else: S[turn + 1] = V[turn2] S[turn] = s0 + s1 - V[turn2] tturn += 1 turn += 1 turn %= 4 TS = tuple(S+[turn]) if TS not in dic: X.append(TS) dic[TS] = tturn else: st = dic[TS] loop = tturn - st N2 = (N - st) % loop print(*X[st+N2][:4]) exit() print(*TS[:4])