Maxwell's Tiles
시간 제한4초메모리 제한2048 MB
정사각형 중심의 max(|x|,|y|) 값이 같은 연결 폴리오미노로 2m 곱하기 2n 벽을 타일링하는 경우의 수를 10^9+7로 나눈 나머지를 구한다.
문제
Maxwell is renovating his bathroom and wants to redo the tiling on his wall. His wall is a 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 , , , and . For example, for , , his wall would look like this:

Maxwell wishes to tile his wall using tiles shaped like connected polyominoes formed from squares, but he has special conditions on how he wants them to be placed. A tile is well-placed if the value of 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 .
입력
The first line of the input contains a single integer () --- the number of test cases. The description of the test cases follows.
Each test case consists of a single line containing two integers and () --- the parameters above, describing the dimensions of Maxwell's wall.
Note that there is no additional constraint on the sum of or 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 .
힌트
Here are the 12 possible tilings for the first sample case:
