The power of Fibonacci
时间限制:C/C++/Rust/Pascal 2秒,其他语言4秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Amy asks Mr. B  problem A. Please help Mr. B to solve the following problem.
Let Fi be fibonacci number.
F0 = 0, F1 = 1, Fi = Fi-1 + Fi-2
Given n and m, please calculate
 
As the answer might be very large, output it module 1000000000.

输入描述:

The first and only line contains two integers n, m(1 <= n <= 1000000000, 1 <= m <= 1000).

输出描述:

Output a single integer, the answer module 1000000000.
示例1

输入

复制
5 5

输出

复制
3402

说明

05 + 15 + 15 + 25 + 35 + 55 = 3402
示例2

输入

复制
10 10

输出

复制
696237975

说明

Don't forget to mod 1000000000
示例3

输入

复制
1000000000 1000

输出

复制
641796875

说明

Time is precious.