Paths of Yin and Yang (Small)

Count the black-and-white colorings of an N by M grid in which each color class forms a single path with two ends.

Hard9CombinatoricsBacktrackingGraphNo attempts yetTime limit30sMemory limit512 MB

Problem

You are given a grid with NN rows and MM columns. Every cell is painted black (yin) or white (yang). Two cells are neighbors when they share an edge segment of length 11. The grid is valid when the black cells form a path and the white cells also form a path.

A set SS of cells is a path when all three conditions below hold.

  • SS is connected. From any cell of SS you reach every other cell of SS by stepping between neighbors that both belong to 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 grid is not valid: its black cells form a path, but its white cells do not.

Given NN and MM, count the valid grids. Symmetry does not matter. Two grids that differ in at least one cell count as different grids, 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 with NN rows and MM columns.

Constraints

  • 1T501 \le T \le 50
  • 4N,M104 \le N, M \le 10