Protocol

Starting from one wire of capacity N, each year every wire splits into two wires transformed by two quadratic polynomials, and after M years we need the sum of 112345 raised to each wire's capacity, mod 1e9+9.

Hard8MathDivide and conquerCombinatoricsRecursionNo attempts yetTime limit2sMemory limit256 MB

Problem

Risha lives in the country of Meiji and built a communication system that runs over wires. In the protocol Risha wrote, every wire has a fixed capacity, and a wire of capacity ii carries ii characters.

Meiji uses 112345 different characters. A wire of capacity ii therefore sends one of 112345i112345^i messages, and the value of that wire is 112345i112345^i.

Meiji has many engineers besides Risha. Every year they take every wire in the country and cut it into two wires with the Banach-Tarski paradox. One wire of capacity XX becomes a wire of capacity f(X)=aX2+bX+cf(X) = aX^2 + bX + c and a wire of capacity g(X)=dX2+eX+fg(X) = dX^2 + eX + f. Start with a single wire of capacity NN. After one year there are two wires, with capacities f(N)f(N) and g(N)g(N). After two years there are four wires, with capacities f(f(N))f(f(N)), f(g(N))f(g(N)), g(f(N))g(f(N)) and g(g(N))g(g(N)). After MM years there are 2M2^M wires built the same way. Find the sum of the values of all wires after MM years.

Input

The first line contains NN and MM, separated by a space.

The second line contains aa, bb, cc, dd, ee, ff, separated by spaces.

All values satisfy 0N,M,a,b,c,d,e,f1000000000=1090 \le N, M, a, b, c, d, e, f \le 1000000000 = 10^9.

Output

Print the sum of the values of all wires after MM years, modulo 1000000009(=109+9)1000000009 (= 10^9 + 9).

Hint

In the first example the total value of the wires is 1123453+1123456112345^3 + 112345^6.