Codeforces Round 323 (Div. 1)
D
Number of Binominal Coefficients
Codeforces
3300
原题
← CE →
翻译中…

For a given prime integer $*p*$ and integers $α, *A*$ calculate the number of pairs of integers $(*n*, *k*)$, such that $0 ≤ *k* ≤ *n* ≤ *A*$ and image is divisible by $*p*^{α}$.

翻译中…

As the answer can be rather large, print the remainder of the answer moduly $10^{9} + 7$.

翻译中…

Let us remind you that image is the number of ways $*k*$ objects can be chosen from the set of $*n*$ objects.

翻译中…

Input

翻译中…

The first line contains two integers, $*p*$ and $α$ ($1 ≤ *p*, α ≤ 10^{9}$, $*p*$ is prime).

翻译中…

The second line contains the decimal record of integer $*A*$ ($0 ≤ *A* < 10^{1000}$) without leading zeroes.

翻译中…

Output

翻译中…

In the single line print the answer to the problem.

翻译中…

Note

翻译中…

In the first sample three binominal coefficients divisible by 4 are image, image and image.

翻译中…

样例

Input #1
2 2
7
Output #1
3
InputCopy OutputCopy
Input #2
3 1
9
Output #2
17
InputCopy OutputCopy
Input #3
3 3
9
Output #3
0
InputCopy OutputCopy
Input #4
2 4
5000
Output #4
8576851
InputCopy OutputCopy
题目信息
题号
582D
时间限制
4 s
内存限制
256 MB
标签
动态规划
数学
数论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。