for _ in range(5): x,y,A,a,b,n=input() exec'A+=a*A[-x]+b*A[-y],;'*n print A[n]
1, 2, [1,1], 1, 1, 6 1, 2, [2, 1], 1, 1, 8 3, 5, [2, 3, 5, 7, 11], 2, 3, 8 1, 3, [-5, 2, 3], 1, 2, 10 5, 7, [-5, 2, 3, -7, -8, 1, -9], -10, -7, 10
13 47 53 -67 39
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!