Skip to content

Latest commit

 

History

History
43 lines (25 loc) · 1.27 KB

Triominoes.md

File metadata and controls

43 lines (25 loc) · 1.27 KB

A triomino is a shape consisting of three squares joined via the edges. There are two basic forms:

image

If all possible orientations are taken into account there are six:

image

Any n by m grid for which n x m is divisible by 3 can be tiled with triominoes.

If we consider tilings that can be obtained by reflection or rotation from another tiling as different there are 41 ways a 2 by 9 grid can be tiled with triominoes:

p_161_k9

In how many ways can a n by m grid be tiled in this way by triominoes? Print answer modulo ((10^9) + 7).

Input Format

First line contains n and m.

Output Format

Print one integer i.e. answer modulo 1000000007 = (10^9) + 7

CONSTRAINTS

1≤ n ≤ 6

1≤ m ≤ 21

n x m is divisible by 3

Sample Input

2 9

Sample Output

41