SP9494 ZSUM - Just Add It
Description
For two given integers n and k find (Z $ _{n} $ + Z $ _{n-1} $ - 2Z $ _{n-2} $ ) mod 10000007, where Z $ _{n} $ = S $ _{n} $ + P $ _{n} $ and S $ _{n} $ = 1 $ ^{k} $ + 2 $ ^{k} $ + 3 $ ^{k} $ + … + n $ ^{k} $ and P $ _{n} $ = 1 $ ^{1} $ + 2 $ ^{2} $ + 3 $ ^{3} $ + … + n $ ^{n} $ .
Input Format
There are several test cases ( For last test case n and k are given as 0 0, which is not to be processed.
Output Format
For each case print the asked value in separate line.