Roses and pots (2)

You have roses of cc different colors. In particular, you have nn roses of each color. Please compute the number of ways to plant all the roses in a line of cncn pots, one rose per pot, in such a way that there is exactly one pair of adjacent roses of the same color. The roses of the same color are indistinguishable.

Input

Input consists of several cases, each with cc and nn. Assume that cc is either 2 or 3. For c=2c = 2, we have 1n1071 \le n \le 10^7. For c=3c = 3, we have 1n2001 \le n \le 200.

Output

For every case, print the answer modulo 108+710^8 + 7.

Problem information

Author: Salvador Roura

Generation: 2026-01-25T10:13:57.318Z

© Jutge.org, 2006–2026.
https://jutge.org