#1982. 下降幂多项式

下降幂多项式

Background

Special for beginners, ^_^

Description

xxkk 次下降幂定义为

x(k)=(x)(x1)(x2)...(xk+1)x^{(k)}=(x)(x-1)(x-2)...(x-k+1)

xx 的下降幂多项式是由 xx 的一组下降幂及系数组成的算式:

$$f(x)=a_nx^{(n)}+a_{n-1}x^{(n-1)}+...+a_2x^{(2)}+a_1x^{(1)}+a_0 $$

给定下降幂多项式 f(x)f(x) 的系数 an,an?1,...a0a_n,a _{n?1},...a_0 与一个值 mm ,请计算 f(m)mod1,000,000,007f(m) \bmod 1,000,000,007

Format

Input

\circ 第一行:两个整数 nnmm

\circ 第二行:n+1n+1 个整数 an,an1,...,a1,a0a_n,a _{n-1},...,a_1,a_0

Output

\circ 单个整数:表示f(m)mod1,000,000,007f(m)\bmod1,000,000,007

Limitation

\circ 40%40\% 的数据, 1n101\leq n \leq 10

\circ 60%60\% 的数据, 1n3,0001\leq n \leq 3,000

\circ 100%100\% 的数据, 1n3,000,0001\leq n \leq 3,000,000

\circ 109m109-10^9\leq m\leq10^{9}

\circ 109ai109-10^9\leq a_i\leq10^{9}

Samples

3 5
4 3 2 1
311
说明:

f(x)=4(x)(x1)(x2)+3(x)(x1)+2(x)+1f(x)=4(x)(x-1)(x-2)+3(x)(x-1)+2(x)+1

f(5)=4(5)(4)(3)+3(5)(4)+2(5)+1=240+60+10+1f(5)=4(5)(4)(3)+3(5)(4)+2(5)+1=240+60+10+1