404520: GYM101522 L Let Me Count The Ways
Description
You are given a grid with two rows. The first row has N cells and the second row has M cells. The cells are aligned to the left boundary of the grid. It is guaranteed that N ≥ M, that is, the first row will not have fewer cells than the second row. By cell (R, C) we mean the cell which is on the R-th row and the C-th column.
For example, below is the grid corresponding to N = 5, M = 3, and the coloured cell is (2, 3):
You now want to fill the grid with integers 1, 2, ..., (N + M - 1), (N + M), one integer per cell. A valid assignment is a way of filling the grid which satisfies the following conditions:
- Each of the integers 1, 2, ..., (N + M - 1), (N + M) appears exactly once;
- For every cell (R, C), if the cell (R + 1, C) exists, then the number on cell (R, C) is greater than that on cell (R + 1, C); and
- For every cell (R, C), if the cell (R, C + 1) exists, then the number on cell (R, C) is greater than that on cell (R, C + 1).
Count the number of valid assignments, modulo 1000000007 ( = 109 + 7). Note that 1000000007 is a prime number.
InputThe first and only line of input consists of two space-separated integers N and M.
For all test cases, 1 ≤ M ≤ N ≤ 109.
OutputOutput the number of valid assignments, modulo 1000000007.
ExamplesInput5 3Output
28Input
2 1Output
2Input
4 4Output
14Input
10 6Output
3640Input
123456789 23456890Output
484500998Input
987654321 896745320Output
0