Solving a Problem (Park Seungwon)
Time limit1sMemory limit512 MB
Count the ways to tile an n×m grid (n, m up to 10) with 1×1, 2×2, and 4×4 tiles, where each size comes in several kinds, modulo 1e9+7.
- Level
Hard8 of 10
- Topics
- Dynamic programming, Combinatorics, Math
- Solved
- No attempts yet
Problem
You cannot submit this problem. See the problem "Solving a Problem".
Park Seungwon could not solve this problem.
Did you know that the logo of the Japanese Olympiad in Informatics forms a fractal?

Park Seungwon uses a "Fractal Park Seungwon", modeled on the JOI logo, as his profile picture. Impressed by it, Bik Seungwin built a factory that makes the tiles for the Fractal Park Seungwon. Infinitely small tiles cannot be made, so the factory makes four kinds of tiles, three kinds of tiles, and three kinds of tiles, as shown below.

Much time has passed. In 2030, the factory makes kinds of tiles, kinds of tiles, and kinds of tiles. Today, Park Seungwon bought tiles of each kind from Bik Seungwin. He wants to fill an grid with these tiles. Each tile used must fit exactly into the cells of the grid, and each cell must be covered by exactly one tile. He wonders how many ways there are to fill the grid.
However, Park Seungwon could not solve this problem.
Input
The first line contains the number of test cases . ()
Each test case is on one line and gives , , , , and . (; )
Output
Print the number of ways to fill the grid, modulo .