Dinamo

Time limit: 4s Memory limit: 256MB Input: Output:

Task

Due to the positive reviews received by the committee regarding a certain problem involving tiling on matrices, we present the following problem:

A tile is called a ketris tile if:

  • It has a rectangular shape, and the lengths of its sides (in meters) are natural numbers.
  • At least one of its sides has a length of 11 meter.

A complete coverage of a surface with ketris tiles is called a ketris tiling.

How many ketris tilings exist for a rectangular surface with side lengths of nn and mm meters? Since the answer can be very large, print the result modulo 109+710^9+7.

Two ketris tilings are considered different if there exists a ketris tile that appears in the first tiling in a certain location but not in the second.

Input data

The first line of the input file contains two natural numbers nn and mm - the height and width of the surface, respectively.

Output data

Print the number of possible ketris tilings. Since the answer can be very large, print it modulo 109+710^9+7.

Constraints and clarifications

  • 1n101 \le n \le 10
  • 1m10181 \le m \le 10^{18}
# Score Restrictions
1 7 n=1n=1
2 4 n=2,m1000n=2,m \le 1000.
3 5 n=2,m106n=2,m \le 10^6.
4 8 n=2,m1018n=2,m \le 10^{18}.
5 13 n,m5n,m \le 5.
6 16 n7,m1000n \le 7, m \le 1000.
7 26 n7n \le 7.
8 21 No additional restrictions

Example 1

stdin

1 4

stdout

8

Explanation

There are 88 possible ketris tilings:

Example 2

stdin

2 2

stdout

7

Explanation

There are 77 possible ketris tilings:

Example 3

stdin

2 3

stdout

29

Example 4

stdin

2 11

stdout

3381689

Example 5

stdin

6 5

stdout

441987135

Example 6

stdin

7 420

stdout

496377800

Log in or sign up to be able to send submissions!