The Paths of Yin Yang (Large)

Count the black-and-white colorings of an N by M grid in which each color forms one edge-adjacent path.

Hard9CombinatoricsGraphNo attempts yetTime limit120sMemory limit512 MB

Problem

You are given a grid with NN rows and MM columns. Each cell is painted black (yin) or white (yang). Two cells are neighbors when they share an edge of unit length. The grid is valid when the black cells form one path and the white cells form one path. A set SS of cells is a path when all three of the following hold.

  • SS is connected. From any cell of SS you reach every other cell of SS by moving between neighbors inside SS.
  • Exactly two cells of SS have exactly one neighbor inside SS. These two cells are the ends of the path.
  • Every other cell of SS has exactly two neighbors inside SS.

In the picture below, the first grid is valid. The second one is not: its black cells form a path, but its white cells do not.

Given NN and MM, count the valid grids. Two valid grids that differ in at least one cell are counted separately, even when a rotation or a reflection turns one into the other.

Input

The first line contains one integer TT, the number of test cases. Each of the next TT lines contains two integers NN and MM separated by a space.

Output

For each test case, print one line in the form Case #x: A, where xx is the test case number starting from 1 and AA is the number of valid grids of the given size.

Constraints

  • 1T501 \le T \le 50
  • 4N,M144 \le N, M \le 14