for _ in range(5):
	x,y,A,a,b,n=input()
	exec'A+=a*A[-x]+b*A[-y],;'*n
	print A[n]