7402 - Toy Distribution   

Description

You are distributing N toys into M boxes, which will be sending as gifts to children. It doesn’t matter each of the boxes is received by whom, but different toys packed into the same box is considered different. That is to say, toys are considered different, but boxes are considered indistinguishable. Count the number of ways to distribute N toys into M boxes, and no boxes should be left empty.

 

Input

Each test case consists of two space-separated integers N and M (1 ≤ MN ≤ 1000) in a line, representing the number of toys and boxes.

The input is terminated by N = M = 0.

 

Output

For each test case, output a line that consists of an integer, representing the total number of ways to distribute these toys, mod 10007.

 

Sample Input  Download

Sample Output  Download

Tags




Discuss