Processing math: 100%

Time Limit : sec, Memory Limit : KB
English / Japanese  

Balls and Boxes 3

BallsBoxesAny wayAt most one ballAt least one ball
DistinguishableDistinguishable123
IndistinguishableDistinguishable456
DistinguishableIndistinguishable789
IndistinguishableIndistinguishable101112

Problem

You have n balls and k boxes. You want to put these balls into the boxes.

Find the number of ways to put the balls under the following conditions:

  • Each ball is distinguished from the other.
  • Each box is distinguished from the other.
  • Each ball can go into only one box and no one remains outside of the boxes.
  • Each box must contain at least one ball.

Note that you must print this count modulo 109+7.

Input

n k

The first line will contain two integers n and k.

Output

Print the number of ways modulo 109+7 in a line.

Constraints

  • 1n1000
  • 1k1000

Sample Input 1

4 3

Sample Output 1

36

Sample Input 2

10 3

Sample Output 2

55980

Sample Input 3

100 100

Sample Output 3

437918130

 
BESsBESsBESsBESsBESsBESsBESsBESs