v1,v2,v3,v4,N = map(int,input().split()) water = [v1,0,0,0] water2 = [] TF = [False]*4 for i in range(N): if i%4 == 0: tmp = v2-water[1] tmp2 = min(tmp,water[0]) water[1]+=tmp2 water[0]-=tmp2 elif i%4 == 1: tmp = v3-water[2] tmp2 = min(tmp,water[1]) water[2]+=tmp2 water[1]-=tmp2 elif i%4 == 2: tmp = v4-water[3] tmp2 = min(tmp,water[2]) water[3]+=tmp2 water[2]-=tmp2 else: tmp = v1-water[0] tmp2 = min(tmp,water[3]) water[0]+=tmp2 water[3]-=tmp2 water2.append(tuple(water)) if i+1 == N: print(*water2[-1]) exit() if i>=4: if water2[i] == water2[i-4]: TF[i%4] = True cnt = 0 for j,v in enumerate(TF): if v: cnt+=1 if cnt == 4 and i%4 == 3: #print("i",i,"打ち切り") break tmp2 = N%4 water2.reverse() #print(water2) #print(tmp2) if tmp2 == 0: print(*water2[0]) elif tmp2 == 1: print(*water2[3]) elif tmp2 == 2: print(*water2[2]) else: print(*water2[1])