from collections import defaultdict v1, v2, v3, v4, N = map(int, input().split()) V = [v1, v2, v3, v4] start = (v1, 0, 0, 0, 0) dist = defaultdict(lambda: -1) status = defaultdict(tuple) now = start d, pt = 0, 0 while dist[now] == -1: dist[now] = d status[d] = now next = list(now) delta = min((V[(pt + 1) % 4] - now[(pt + 1) % 4]), now[pt]) next[pt] -= delta next[(pt + 1) % 4] += delta next[-1] = (next[-1] + 1) % 4 d, pt = d + 1, (pt + 1) % 4 now = tuple(next) # print(now) # print(d) cycle_length = d - dist[now] # print(cycle_length) if N < d: exit(print(*status[d-1][:-1])) N -= d - cycle_length N %= cycle_length print(*status[(d - cycle_length + N)][:-1])