Tukuai, the gambling monster, is playing a gambling game with a machine consisting of a turntable and a display screen.
The turntable is divided into

parts, numbered

. The area of the

-th part is

, which means the probability of getting integer

is

, if the player turn the turntable once.
An integer

will be displayed on the screen during the game. At the beginning,

. The goal of the game is to make

to get the prize. The player can do the following operation any times before

(If

, the game ends immediately):
Pay one coin and turn the turntable once, then get an integer

. The player can choose to make

, or keep

unchanged, where

is bitwise-xor operation.
As a gambling monster, Tukuai is greedy, so he will make

once

, or keep

unchanged if

.
What is the expected number of coins that need to be paid by Tukuai to get the prize? Find the answer modulo
. Or formally, let
. It can be shown that the answer can be expressed as an irreducible fraction
, where
. Find the value
.
The first line of the input contains an integer
&preview=true)
, representing the number of test cases.
The first line of each test case contains an integer

(

and

is a power of

).
The second line of each test case contains

integers
&preview=true)
.
It is guaranteed that the sum of
over all test cases does not exceed
.