Function Counting

아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

Let MM be the set of integers at most nn by absolute value, that is, M=xZ ⁣:xnM = \\{ x \in \mathbb{Z}\colon |x| \le n \\}.

Let f_k(x)f\_k (x) be the function ff applied kk times to an initial value xx, that is, f_0(x)=xf\_0 (x) = x and f_i(x)=f(f_i1(x))f\_i (x) = f (f\_{i - 1} (x)) for any i1i \ge 1.

Given the integers nn and kk, count the number of functions f(x)f (x) satisfying the following conditions:

  1. f ⁣:MMf\colon M \to M,
  2. xM ⁣:f_k(x)=x\forall x \in M\colon f\_k (x) = -x,
  3. xM ⁣:(f(x)x)2\forall x \in M\colon |(|f (x)| - |x|)| \le 2.

As the answer may be very large, print it modulo 109+710^9 + 7.

입력

The first line of input contains an integer TT, the number of test cases (1T1001 \le T \le 100).

Each test case contains a pair of positive integers nn and kk (nk109n \cdot k \le 10^9).

The total sum of nkn \cdot k over all test cases does not exceed 41094 \cdot 10^9.

출력

For each test case, output the answer modulo 109+710^9 + 7 on a separate line.

힌트

If k=1k = 1, only the function f(x)=xf(x) = -x satisfies all requirements.

If n=k=2n = k = 2, two functions exist:

  • (2,1,0,1,2)(1,2,0,2,1)(-2, -1, 0, 1, 2) \to (1, -2, 0, 2, -1) and
  • (2,1,0,1,2)(1,2,0,2,1)(-2, -1, 0, 1, 2) \to (-1, 2, 0, -2, 1).