#PIBO. Fibonacci vs Polynomial
Fibonacci vs Polynomial
Define a sequence Pib(n) as following
- Pib(0) = 1
- Pib(1) = 1
- otherwise, Pib(n) = Pib(n-1) + Pib(n-2) + P(n)
Here P is a polynomial.
Given n and P, find Pib(n) modulo 1,111,111,111.
Input
First line of input contains two integer n and d (0 ≤ n ≤ 109, 0 ≤ d ≤ 100), d is the degree of polynomial.
The second line contains d+1 integers c0, c1 … cd, represent the coefficient of the polynomial (Thus P(x) can be written as Σcixi). 0 ≤ ci ≤ 100 and cd ≠ 0 unless d = 0.
Output
A single integer represents the answer.
Example
Input: 10 0 0Output: 89
Input: 10 0 1</p>Output: 177
Input: 100 1 1 1</p></p>Output: 343742333