There is a lottery box, and the lottery action corresponds to an
n×nn \times nn×n matrix. Each cell in the matrix has a light bulb, which is initially turned off. Each time a lottery is drawn, a specific light bulb will be attempted to be turned on, each with a fixed probability, even if the light bulb is already on. Once a light bulb is turned on, it will remain on. In other words, each time a lottery is drawn, there is a probability of
pi,jp_{i, j}pi,j of selecting the light bulb in the
iii-th row and
jjj-th column, or indexed
(i,j)(i, j)(i,j), and attempting to turn it on (
1≤i,j≤n1 \leq i, j \leq n1≤i,j≤n). If the light is already on, this operation is ignored.
Whenever all the light bulbs in a particular row, column, or diagonal are turned on, the organizer will give the player a special gift corresponding to that line. There are (2n+2)(2 n + 2)(2n+2) types of gifts, numbered from 000 to (2n+1)(2 n + 1)(2n+1), each type of gift corresponds to exactly one of the aforementioned lines, and each line corresponds to exactly one type of the gifts.
Pla
yers have a special fondness for certain gifts and are eager to know the expected number of lottery draws needed to obtain these gifts, so they come to you. You need to answer qqq queries, where the iii-th query corresponds to a number tit_iti (0<ti<22n+20 < t_i < 2^{2 n + 2}0<ti<22n+2). Let the binary representation of tit_iti in length (2n+2)(2 n + 2)(2n+2) be (b2n+1b2n⋯b0)2(b_{2 n + 1} b_{2 n} \cdots b_0)_2(b2n+1b2n⋯b0)2 such that 
and bj∈{0,1}b_j \in \{0, 1\}bj∈{0,1}. If bj=1b_j = 1bj=1, it indicates that the query requires obtaining the gift jjj, and you need to calculate the expected number of lottery draws with respect to these gifts, in modulo (109+7) (for more details, check the output format).