import nntplib import sys import math import heapq from collections import deque, Counter, defaultdict from sys import stdin INF = 10 ** 7 int1 = lambda x: int(x) - 1 stinput = lambda: stdin.readline()[:-1] ii = lambda: int(stinput()) # int input mi = lambda: map(int, stdin.readline().split()) # map input (int) li = lambda: list(mi()) # list input (int) mi1 = lambda: map(int1, stdin.readline().split()) # map input (int)-1 li1 = lambda: list(mi1()) # list input (int)-1 mis = lambda: map(str, stdin.readline().split()) # map input (string) lis = lambda: list(mis()) # list input (string) *V, N = mi() nV = [V[i] if not(i) else 0 for i in range(4)] d = {(V[0], 0, 0, 0): 0} d2 = {0: (V[0], 0, 0, 0)} for n in range(N): pV = [nV[i] for i in range(4)] if n % 4 == 0: nV[1] = min(V[1], pV[1] + pV[0]) nV[0] = pV[0] - (nV[1] - pV[1]) elif n % 4 == 1: nV[2] = min(V[2], pV[2] + pV[1]) nV[1] = pV[1] - (nV[2] - pV[2]) elif n % 4 == 2: nV[3] = min(V[3], pV[3] + pV[2]) nV[2] = pV[2] - (nV[3] - pV[3]) else: nV[0] = min(V[0], pV[0] + pV[3]) nV[3] = pV[3] - (nV[0] - pV[0]) tnV = tuple(nV) if tnV in d: d[(N, N, N, N)] = n + 1 d2[n + 1] = tnV roopStart = d[tnV] roopEnd = n + 1 a = nV break else: d[tnV] = n + 1 d2[n + 1] = tnV if n == N - 1: print(*nV) exit() print(*d2[roopStart + (N - roopStart) % (roopEnd - roopStart)])