QOJ.ac

QOJ

時間限制: 2 s 記憶體限制: 1024 MB 總分: 100 可 Hack ✓

#17937. Chocolate Begins

统计

Coco is playing Tic-Tac-Toe with Hanbyeol using white and dark chocolates. The rules of Tic-Tac-Toe are as follows:

  • Prepare a game board with a $3 \times 3$ grid.
  • Two players take turns placing a chocolate in an empty cell on the board. The first player places white chocolate, and the second player places dark chocolate. A chocolate cannot be placed in a cell that is already occupied.
  • The player who first places 3 chocolates of the same color in a horizontal, vertical, or diagonal line wins. If the board is full and no one has won, the game is a draw.

Coco grew bored of the game always ending in a draw and began to wonder: if two people cooperate to create a drawn game on an $N \times M$ board, how many different game boards can result? Let's help Coco solve this. Even if the board size changes, a player wins if they place 3 consecutive chocolates in a horizontal, vertical, or diagonal line.

Two game boards are considered different if there is at least one cell with a different chocolate at the same coordinate. If the final positions of the chocolates are identical, the boards are considered the same, regardless of the order in which the chocolates were placed. "Diagonal" refers only to the 45-degree directions (down-right and up-right).

(Explanation for Example 1)

There are 16 possible drawn game boards on a $3 \times 3$ board, as shown below:

Input

The integers $N$ and $M$ are given on the first line. ($1 \le N, M \le 1000$)

Output

Output the number of different drawn game boards that can result from a Tic-Tac-Toe game on an $N \times M$ board, modulo $10^9+7$.

Examples

Input 1

3 3

Output 1

16

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.