首页 > 试题广场 >

Monotonic Matrix

[编程题]Monotonic Matrix
Count the number of n x m matrices A satisfying the following condition modulo (109+7).
* Ai, j ∈ {0, 1, 2} for all 1 ≤ i ≤ n, 1 ≤ j ≤ m.
* Ai, j ≤ Ai + 1, j for all 1 ≤ i < n, 1 ≤ j ≤ m.
* Ai, j ≤ Ai, j + 1 for all 1 ≤ i ≤ n, 1 ≤ j < m.

输入描述:
The input consists of several test cases and is terminated by end-of-file.
Each test case contains two integers n and m.


输出描述:
For each test case, print an integer which denotes the result.
示例1

输入

1 2
2 2
1000 1000

输出

6
20
540949876

备注:
* 1 ≤ n, m ≤ 103
* The number of test cases does not exceed 105.

这道题你会答吗?花几分钟告诉大家答案吧!