#P17341. 【MX-X30-T7】言而无信者的救赎

【MX-X30-T7】言而无信者的救赎

Background

Even if I myself will be drowned in

endless sorrow,

I will still return to blankness,

to a blank future.

Problem Description

For a permutation pp of length 2n2n, define f(p)f(p) as the number of integer pairs (i,j)(i, j) that satisfy the following conditions:

  • 1≤i,j≤n1 \le i, j \le n.
  • p2i=2jp_{2i} = 2j.
  • p2i−1=2j−1p_{2i-1} = 2j-1.

Define c(p)c(p) as the number of permutation cycles of pp.

For i=0∼ni = 0 \sim n and j=1∼2nj = 1 \sim 2n, please compute the number of permutations pp such that f(p)=if(p) = i and c(p)=jc(p) = j, taken modulo 109+710^9 + 7, denoted as H(i,j)H(i, j).

Please compute $\displaystyle \bigoplus_{i=0}^n \bigoplus_{j=1}^{2n} \left(d + H(i, j)\right)$.

Input Format

This problem contains multiple test cases.

The first line contains an integer TT.

The next TT lines each contain two integers n,dn, d.

Output Format

Output TT lines in total. For each test case, output one integer per line, representing $\displaystyle \bigoplus_{i=0}^n \bigoplus_{j=1}^{2n} \left(d + H(i, j)\right)$.

3
2 0
10 0
100 0
10
836833797
850061004
3
1000 1
2000 2
4000 45
300382194
871761782
343429692

Hint

For all data, it is guaranteed that 1≤T≤31 \le T \le 3, 1≤n≤40001 \le n \le 4000, and 0≤d≤1000 \le d \le 100.

::cute-table{tuack}

Subtask ID Score n≤n \le
11 55
22 1010 1515
33 1515 5050
44 2020 250250
55 20002000
66 30003000
77 1010 40004000

Translated by ChatGPT 5