from collections import defaultdict v1, v2, v3, v4, N = map(int, input().split()) V = [v1, v2, v3, v4] start = (v1, 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 d, pt = d + 1, (pt + 1) % 4 now = tuple(next) cycle_length = d - dist[now] if N < d: exit(print(*status[d-1])) N -= d - cycle_length N %= cycle_length print(*status[d - cycle_length + N])