#CF2239A. Nim 游戏就是异或游戏 / A. Nim Game Is XOR Game

Nim 游戏就是异或游戏 / A. Nim Game Is XOR Game

A. Nim Game Is XOR Game

Source: Codeforces 2239A
Contest: Codeforces Round 1105 (Div. 1)
Time limit: 2 seconds
Memory limit: 256 megabytes

Statement

Alice and Bob are playing a game with an array aa consisting of nn non-negative integers. Alice goes first.

In each turn, the current player must choose an array of nn non-negative integers b=[b1,b2,,bn]b = [b_1, b_2, \ldots, b_n] that satisfies the following conditions:

  • 0biai0 \le b_i \le a_i for all 1in1 \le i \le n;
  • i=1nbi>0\sum_{i=1}^n b_i \gt 0 (i.e. the array bb does not consist entirely of zeros);
  • b1b2bn=0b_1 \oplus b_2 \oplus \ldots \oplus b_n = 0, where \oplus denotes the bitwise XOR operation.

After choosing the array bb, the player updates the array aa by performing aiaibia_i \leftarrow a_i - b_i for all 1in1 \le i \le n.

The player who cannot perform such an operation loses the game.

Determine the number of valid choices for the array bb that Alice can make on her first turn to guarantee a win, assuming both players play optimally. Since this number may be large, output the answer modulo 998244353998\,244\,353.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t1041 \le t \le 10^4). The description of the test cases follows.

The first line of each test case contains a single integer nn (1n1061 \le n \le 10^6) — the length of the array aa.

The second line of each test case contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n (1ai<2301 \le a_i \lt 2^{30}) — the contents of the array aa

It is guaranteed that the sum of nn over all test cases does not exceed 10610^6.

Output

For each test case, output the number of valid choices for the array bb that Alice can make on her first turn to guarantee a win modulo 998244353998\,244\,353.

Note

In the first test case, Alice must choose an array bb of length 11. The conditions require b1a1b_1 \le a_1, b1>0b_1 \gt 0, and b1=0b_1 = 0. It is impossible to satisfy b1>0b_1 \gt 0 and b1=0b_1 = 0 simultaneously. Thus, Alice has no valid moves and loses immediately. The answer is 00.

In the second test case, a=[1,2]a = [1, 2]. Alice must choose b=[b1,b2]b = [b_1, b_2]. The condition b1b2=0b_1 \oplus b_2 = 0 implies that b1=b2b_1 = b_2. Since 0b110 \le b_1 \le 1 and 0b220 \le b_2 \le 2, and the array bb cannot consist entirely of zeros, the only valid choice is b=[1,1]b = [1, 1]. If Alice chooses b=[1,1]b = [1, 1], the array updates to a=[11,21]=[0,1]a = [1-1, 2-1] = [0, 1]. Now it is Bob's turn. Similar to Alice's situation, Bob must choose bb' such that b1=b2b'_1 = b'_2. Since a1=0a_1 = 0, he is forced to pick b1=0b'_1 = 0, which means b2=0b'_2 = 0. Since a valid move must have bi>0\sum b'_i \gt 0, Bob has no valid moves and loses. Therefore, b=[1,1]b = [1, 1] is a winning move for Alice, and the answer is 11.

Examples

5
1
1
2
1 2
5
1 4 5 2 6
1
1073741823
3
1 2 3
0
1
3
0
1