#P3266. Matrix Array Count with Strict Conditions

    ID: 16523 Type: Default 1000ms 256MiB

Matrix Array Count with Strict Conditions

Matrix Array Count with Strict Conditions

We are given two integers (n) and (m). Consider an (n \times m) array (x_{i,j}) (with (1 \le i \le n) and (1 \le j \le m)) where every element satisfies (0 \le x_{i,j} \le m). The array is valid if it fulfills the following conditions:

  1. For every row (i) and every column (j) with (1 \le j < m), we have (x_{i,j} < x_{i,j+1}).
  2. For every row (i) with (2 \le i \le n) and every column (j) with (1 \le j < m), we require (x_{i,j} < x_{i-1,j+1}).

It can be observed that every row, being a strictly increasing sequence chosen from ({0,1,\ldots,m}), is uniquely determined by which number from (0) to (m) is omitted. Let (r_i) be the number omitted in row (i). Hence, the row is the sorted list of ({0,1,\ldots,m}\setminus{r_i}). With this representation, the additional condition between consecutive rows (row (i-1) with missing number (b) and row (i) with missing number (a)) is equivalent to

[ a + 1 \ge b \quad \text{or equivalently} \quad a \ge b - 1. ]

Your task is to count the number of valid arrays modulo (10^9+7).

inputFormat

The input consists of two space-separated integers (n) and (m).

outputFormat

Output a single integer: the number of valid arrays modulo (10^9+7).

sample

1 1
2