""" 高々comb(103, 3)通り """ X = list(map(int, input().split())) N = X.pop() W = [0] * 4 W[0] = X[0] used = set() memo = [] for i in range(10 ** 9): used.add(tuple(W)) memo.append(tuple(W)) i %= 4 j = (i + 1) % 4 wi = W[i] wj = X[j] - W[j] d = min(wi, wj) W[i] -= d W[j] += d if tuple(W) in used: break if len(memo) > N: print(*memo[N]) exit() f = memo.index(tuple(W)) s = len(memo) - f N -= f N %= s print(*memo[f + N])