404520: GYM101522 L Let Me Count The Ways

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

L. Let Me Count The Waystime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

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.

Input

The first and only line of input consists of two space-separated integers N and M.

For all test cases, 1 ≤ M ≤ N ≤ 109.

Output

Output the number of valid assignments, modulo 1000000007.

ExamplesInput
5 3
Output
28
Input
2 1
Output
2
Input
4 4
Output
14
Input
10 6
Output
3640
Input
123456789 23456890
Output
484500998
Input
987654321 896745320
Output
0

加入题单

算法标签: