Assume that *s*<sub class="lower-index">*k*</sub>(*n*) equals the sum of digits of number *n* in the *k*-based notation. For example, *s*<sub class="lower-index">2</sub>(5) = *s*<sub class="lower-index">2</sub>(101<sub class="lower-index">2</sub>) = 1 + 0 + 1 = 2, *s*<sub class="lower-index">3</sub>(14) = *s*<sub class="lower-index">3</sub>(112<sub class="lower-index">3</sub>) = 1 + 1 + 2 = 4.

The sequence of integers *a*<sub class="lower-index">0</sub>, ..., *a*<sub class="lower-index">*n* - 1</sub> is defined as <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/3d69672a1eeecefd43ff353cc9755741cf4b9b57.png" style="max-width: 100.0%;max-height: 100.0%;"/>. Your task is to calculate the number of distinct subsequences of sequence *a*<sub class="lower-index">0</sub>, ..., *a*<sub class="lower-index">*n* - 1</sub>. Calculate the answer modulo 10<sup class="upper-index">9</sup> + 7.

Sequence *a*<sub class="lower-index">1</sub>, ..., *a*<sub class="lower-index">*k*</sub> is called to be a subsequence of sequence *b*<sub class="lower-index">1</sub>, ..., *b*<sub class="lower-index">*l*</sub>, if there is a sequence of indices 1 ≤ *i*<sub class="lower-index">1</sub> &lt; ... &lt; *i*<sub class="lower-index">*k*</sub> ≤ *l*, such that *a*<sub class="lower-index">1</sub> = *b*<sub class="lower-index">*i*<sub class="lower-index">1</sub></sub>, ..., *a*<sub class="lower-index">*k*</sub> = *b*<sub class="lower-index">*i*<sub class="lower-index">*k*</sub></sub>. In particular, an empty sequence (i.e. the sequence consisting of zero elements) is a subsequence of any sequence.
The first line contains two space-separated numbers *n* and *k* (1 ≤ *n* ≤ 10<sup class="upper-index">18</sup>, 2 ≤ *k* ≤ 30).
print("_RANDOM_GUESS_1689637814.4355159")# 1689637814.435537