Under construction

Still being built. Things may change

Knight Moves 2

Time limit2sMemory limit512 MB

Summary
Count knight paths of length at most k on a 2n by 2n board that start at the top-left corner and end on any corner, modulo 1000007.
Level

Hard8 of 10

Topics
Matrix, Dynamic programming, Graph
Solved
No attempts yet

Problem

A knight stands on the top-left square of a 2n×2n2n \times 2n chessboard. In one move the knight goes two squares in one direction and one square in the perpendicular direction, so its row and column change by (±1,±2)(\pm 1, \pm 2) or (±2,±1)(\pm 2, \pm 1). A move that leaves the board is not allowed.

The corner squares are the four squares at the corners of the board: top-left, top-right, bottom-left, and bottom-right.

Count the ways to make at most kk moves and finish on a corner square. Two ways are different if they use a different number of moves, or if they visit a different sequence of squares. The knight already stands on the top-left corner at the start, so making no move at all counts as one way.

Stated another way, for every tt with 0≤t≤k0 \le t \le k, count the paths that start on the top-left square, make exactly tt moves, and end on a corner square, then add all of those counts. A path may revisit a square, and it may enter a corner square and leave it again.

Input

The first line contains the number of test cases TT (1≤T≤501 \le T \le 50).

Each of the next TT lines contains one test case: two integers nn and kk separated by a space (2≤n≤242 \le n \le 24, 1≤k≤1091 \le k \le 10^9).

Output

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

Examples2

  1. Example 1

    Input
    3
    2 1
    2 2
    3 3
    
    Expected output
    1
    5
    7
    
  2. Example 2

    Input
    2
    3 1
    4 4
    
    Expected output
    1
    19