Knight Moves to a Corner

Count knight walk sequences of length at most k starting from a board corner and ending on any corner of a 2n x 2n board, modulo 1000007.

Medium6Dynamic programmingMatrixGraphNo attempts yetTime limit5sMemory limit512 MB

Problem

A knight stands on the top left square of a 2n×2n2n \times 2n chessboard. In one move the knight goes 1 square in one direction and 2 squares in the perpendicular direction, and it may not leave the board. It may step on a square it has already visited.

Count the ways to move the knight at least 00 and at most kk times so that it ends on one of the four corner squares of the board. Two ways are different if the number of moves differs, or if the sequence of visited squares differs anywhere. The starting square is already a corner, so making no move at all counts as one way.

Input

The first line contains the number of test cases TT (1T201 \le T \le 20).

Each of the next TT lines holds one test case with nn and kk separated by a space (2n122 \le n \le 12, 1k1091 \le k \le 10^9).

Output

For each test case, print the number of ways modulo 10000071000007 on its own line.