Eel and Grid

아직 제출이 없습니다시간 제한1초메모리 제한256 MB

문제

There is an H×WH \times W grid. Let (i, j)(i,\ j) be the cell at the intersection of the ii-th row (0iH10 \leq i \leq H-1) and the jj-th column (0jW10 \leq j \leq W-1). Initially, there is an eel at the cell (0, 0)(0,\ 0). The eel repeats the following process.

  • If the current cell is painted, end the process.
  • If the current cell is not painted, paint the cell and move to another cell. If the current cell is (i, j)(i,\ j), the new cell must be either ((i+1) mod H, j)((i+1)\ {\rm mod}\ H,\ j) or (i, (j+1) mod W)(i,\ (j+1)\ {\rm mod}\ W).

Count the number of ways to paint all cells and end the process at the cell (0, 0)(0,\ 0), modulo 109+710^9+7. Two ways are considered distinct if the path traveled by the eel are distinct.

입력

HH WW

출력

Print the answer modulo 109+710^9+7.

제한

  • 2H,W1062 \leq H, W \leq 10^6

힌트

The following picture shows the two ways in Sample 1: