Maxwell's Tiles

시간 제한4초메모리 제한2048 MB

요약
정사각형 중심의 max(|x|,|y|) 값이 같은 연결 폴리오미노로 2m 곱하기 2n 벽을 타일링하는 경우의 수를 10^9+7로 나눈 나머지를 구한다.
난이도

어려움10점 중 8점

유형
조합론, 수학, 동적 계획법
정답자
아직 제출이 없습니다

문제

Maxwell is renovating his bathroom and wants to redo the tiling on his wall. His wall is a 2m×2n2m \times 2n rectangle. To describe the placement of tiles on the wall, we will use a coordinate system placing the center at the origin, so that the wall is described by the rectangle with vertices (m,n)(m, n), (m,−n)(m, -n), (−m,−n)(-m, -n), and (−m,n)(-m, n). For example, for m=3m=3, n=2n=2, his wall would look like this:

Maxwell wishes to tile his wall using tiles shaped like connected polyominoes formed from 1×11 \times 1 squares, but he has special conditions on how he wants them to be placed. A tile is well-placed if the value of max⁡(∣x∣,∣y∣)\max(|x|, |y|) is constant across all the centers of the squares making up that tile. These tiles are allowed to have "holes" in the middle, as long as the tile itself is one connected group.

For example, one possible well-placed tiling of the above wall would be:

How many ways can Maxwell tile his bathroom wall with well-placed tiles? Two configurations of tiles are considered different if two squares are part of the same tile in one configuration but are part of different tiles in the other.

Since the answer may be very large, print it modulo 109+710^9 + 7.

입력

The first line of the input contains a single integer tt (1≤t≤1041 \le t \le 10^4) --- the number of test cases. The description of the test cases follows.

Each test case consists of a single line containing two integers mm and nn (1≤m,n≤1061 \le m, n \le 10^6) --- the parameters above, describing the dimensions of Maxwell's wall.

Note that there is no additional constraint on the sum of nn or mm across all test cases.

출력

For each test case, output a single integer --- the number of ways Maxwell can tile his wall with well-placed tiles, modulo 109+710^9 + 7.

힌트

Here are the 12 possible tilings for the first sample case:

예제1

  1. 예제 1

    입력
    4
    1 1
    3 1
    2 3
    5 4
    
    예상 출력
    12
    192
    3136512
    734798461