V = list(map(int, input().split())) N = V.pop() D = dict() now = (V[0], 0, 0, 0) cnt = 0 D[now] = cnt L = [now] 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] nex = tuple(nex) if nex in D: N -= D[nex] loop = cnt - D[nex] + 1 L = L[D[nex]:] print(*L[N%loop]) exit() else: cnt += 1 D[nex] = cnt L.append(nex) if cnt == N: print(*nex) exit() now = nex