#A. Bitwise Password

    传统题 1000ms 256MiB

Bitwise Password

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Description

Libra wrote down an array of non-negative integers a1,a2,,ana_1,a_2,\dots, a_n. For each continuous subsequence {al,al+1,,ar}\{a_l,a_{l+1},\dots,a_r\} of the array, Libra can calucate its bitwise-xor sum: $a_l\;\mathrm{xor}\;a_{l+1}\;\mathrm{xor}\;\dots \;\mathrm{xor}\; a_r$. (xor represents ^ in C/C++)

Libra gives you mm queries, each of which is described by an integer xix_i. For each query, you need to find a continuous subsequence with minimum value of xiR|x_i-R|, where RR is the bitwise-xor sum of the subsequence. You should tell Libra the length of the corresponding sequence.

If there are multiple subsequences that meet the conditions, tell Libra the longest length of these subsequences.

Format

Input

The first line contains one integer T(1T100)T(1\le T\le 100) --- the number of test cases.

Each test case consists of two lines.

The first line contains N+1N+1 non-negative integers. The first number is N(1N100)N(1\le N\le 100) --- the length of the array. The next NN numbers describe the array {ai}\{a_i\} Libra wrote down.(ai1024)(a_i\le 1024)

The first line contains M+1M+1 integers. The first number is M(1M100)M(1\le M\le 100) --- the number of queries. The next MM numbers xi(xi1024)x_i(|x_i|\le 1024) describe the queries.

Output

For each test case, print M+1M+1 lines. The first MM lines contains the answer to the MM queries, and the (M+1)(M+1)-th line left empty.

Samples

2
2 1 1
2 0 2
3 1 2 4
3 10 5 1
2
1

3
2
1

五一欢乐训练赛

未参加
状态
已结束
规则
ACM/ICPC
题目
6
开始于
2023-5-2 14:00
结束于
2023-5-2 18:00
持续时间
4 小时
主持人
参赛人数
6