Linear Recurrence RNG

Given the first k terms and coefficients of a linear recurrence and a huge index N, compute the N-th term modulo 104857601.

Hard8MathDivide and conquerNumber theoryNo attempts yetTime limit15sMemory limit512 MB

Problem

You are writing a random number generator (RNG) for a lottery auto-submit program. The generator builds a sequence AA from the linear recurrence below.

Ai=(Ai1C1+Ai2C2++AikCk)mod104857601(i>k)A_i = (A_{i-1} C_1 + A_{i-2} C_2 + \cdots + A_{i-k} C_k) \bmod 104857601 \qquad (i > k)

Given kk and NN, the initial terms A1,A2,,AkA_1, A_2, \ldots, A_k, and the coefficients C1,C2,,CkC_1, C_2, \ldots, C_k, write a program that computes ANA_N.

Input

The first line contains kk and NN, separated by a space. (1k300001 \le k \le 30000, 1N10181 \le N \le 10^{18})

The second line contains A1,A2,,AkA_1, A_2, \ldots, A_k, separated by spaces.

The third line contains C1,C2,,CkC_1, C_2, \ldots, C_k, separated by spaces. (0Ai,Ci<1048576010 \le A_i, C_i < 104857601)

Output

Print ANA_N on the first line. ANA_N is always smaller than 104857601.