#P5005. Non‐Attacking Chinese Chess Horses

    ID: 18243 Type: Default 1000ms 256MiB

Non‐Attacking Chinese Chess Horses

Non‐Attacking Chinese Chess Horses

You are given a chessboard with X rows and Y columns, and an unlimited number of identical Chinese chess horses. Note that the movement of a Chinese chess horse is different from that of an international chess knight.

A Chinese chess horse moves as follows: from its current square, it first attempts to move one step in one of the four cardinal directions. If that adjacent square (called the "horse-leg") is empty, then it may continue by moving one step diagonally outward. Thus, there are potentially 8 moves:

  • Up‐Left: first move (-1, 0) then move (-1, -1) (overall (-2, -1)).
  • Up‐Right: first move (-1, 0) then move (-1, +1) (overall (-2, +1)).
  • Down‐Left: first move (+1, 0) then move (+1, -1) (overall (+2, -1)).
  • Down‐Right: first move (+1, 0) then move (+1, +1) (overall (+2, +1)).
  • Left‐Up: first move (0, -1) then move (-1, -1) (overall (-1, -2)).
  • Left‐Down: first move (0, -1) then move (+1, -1) (overall (+1, -2)).
  • Right‐Up: first move (0, +1) then move (-1, +1) (overall (-1, +2)).
  • Right‐Down: first move (0, +1) then move (+1, +1) (overall (+1, +2)).

You need to choose a way to place horses on the board (or leave some squares empty) such that no horse can attack another. Here, a horse at square \((i,j)\) is said to attack another horse at square \((k,l)\) if and only if there exists one of the 8 moves above from \((i,j)\) that would reach \((k,l)\) provided that the intermediate square is empty. Note that if the intermediate (or "blocking") square is occupied by a horse, then that particular move is blocked.

Since the number of valid arrangements may be huge, output the answer modulo \(10^9+7\).

inputFormat

The input consists of a single line containing two integers X and Y (1 \le X, Y), representing the number of rows and columns of the chessboard.

X Y

outputFormat

Output a single integer denoting the number of valid arrangements modulo \(10^9+7\).

sample

1 1
2