Under construction

Still being built. Things may change

Solving a Problem (Park Seungwon)

Time limit1sMemory limit512 MB

Summary
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 1×11 \times 1 tiles, three kinds of 2×22 \times 2 tiles, and three kinds of 4×44 \times 4 tiles, as shown below.

Much time has passed. In 2030, the factory makes VeVe kinds of 1×11 \times 1 tiles, YdYd kinds of 2×22 \times 2 tiles, and PzPz kinds of 4×44 \times 4 tiles. Today, Park Seungwon bought 101810^{18} tiles of each kind from Bik Seungwin. He wants to fill an n×mn \times m 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 TT. (T≤10T \le 10)

Each test case is on one line and gives nn, mm, VeVe, YdYd, and PzPz. (1≤n,m≤101 \le n, m \le 10; 0≤Ve,Yd,Pz≤1090 \le Ve, Yd, Pz \le 10^9)

Output

Print the number of ways to fill the grid, modulo 109+710^9+7.

Examples1

  1. Example 1

    Input
    5
    2 1 2 0 0
    5 3 1 1 1
    2 4 2 1 0
    4 4 1 1 1
    10 10 4 3 3
    
    Expected output
    4
    21
    305
    36
    6910035