V = list(map(int, input().split())) N = V.pop() D = dict() now = (V[0], 0, 0, 0) cnt = 0 D[now] = cnt L = [(V[0], 0, 0, 0, 0)] while True: # print("test", cnt, now) i = cnt%4 ni = (i + 1)%4 nex = [0] * 4 if now[i] + now[ni] >= V[ni]: nex[ni] = V[ni] nex[i] = now[i] + now[ni] - V[ni] else: nex[ni] = now[i] + now[ni] nex[i] = 0 for j in range(4): if j not in [i, ni]: nex[j] = now[j] key = tuple(nex + [cnt%4]) nex = tuple(nex) if key in D: N -= D[key] loop = cnt - D[key] + 1 L = L[D[key]:] print(*L[N%loop]) exit() else: cnt += 1 D[key] = cnt L.append(nex) if cnt == N: print(*nex) exit() now = nex