**16 人解决**，18 人已尝试。

**19 份提交通过**，共有 34 份提交。

**4.0** EMB 奖励。

**单点时限: **2.0 sec

**内存限制: **256 MB

Professor Shekhu was a famous scientist working in the field of game theory in the early days of computer science. Right now, he’s working on a game which involves a box containing $N$ distinct cards. The $i$-th of these cards has a red number written on one side, and a blue number written on the other side. Both of these numbers are positive integers. The game proceeds as follows:

- The player starts with a total of $0$ points. The objective of the game is to finish with the lowest possible total.
- As long as there are at least two cards remaining in the box, the player must repeat the following move:
- Remove two cards of their choice from the box. Choose a red number $R$ from one card and a blue number $B$ from the other card.
- Add the value $R \oplus B$ to the total, where $\oplus$ denotes bitwise XOR operation.
- Return one of the two cards to the box, and remove the other from the game.

- The game ends when there is only one card remaining in the box (and so it is impossible to make another move).
- Professor Shekhu has summoned his best student, Akki, to play this game. Can you help Akki find the minimum possible total, considering all possible ways in which he can play the game?

The first line of the input contains an integer $T$, the number of test cases. $T$ test cases follow; each test case consists of three lines:

First line of the each test case will contain an integer $N$.

- The first line contains a positive integer $N$: the number of cards in the box.
- The second line contains a list of $N$ positive integers $R_i$; the $i$-th of these represents the red number on the $i$-th card.
- The third line contains a list of $N$ positive integers $B_i$; the $i$-th of these represents the blue number on the $i$-th card.

Limits:

- $1 \le T \le 100, 1 \le R_i \le 10^9, 1 \le B_i \le 10^9$.
- Small dataset: $2 \le N \le 5$.
- Large dataset: $2 \le N \le 100$.

For each test case, output one line containing `Case #x: y`

, where `x`

is the test case number (starting from 1) and `y`

is the minimum possible total that Akki can attain, if he plays optimally.

Input

2 2 1 2 3 3 3 1 101 501 3 2 3

Output

Case #1: 1 Case #2: 5

In Sample Case #1, Akki has only one move in which he picks up the available cards and has two options.

- He can choose red number from the first card and blue number from the second card to add 1 ^ 3 = 2 to the total.
- He can choose red number from the second card and blue number from the first card to add 2 ^ 3 = 1 to the total.

The second option is better and the answer is 1.

In Sample Case #2, one optimal strategy is to take the red number from first card and the blue number from second card, add 1 ^ 2 = 3 to the total, and return first card to the box. Then, take the red number from first card and the blue number from third card, add 1 ^ 3 = 2 to the total, and return either of the cards to the box. The final total is 5.

**16 人解决**，18 人已尝试。

**19 份提交通过**，共有 34 份提交。

**4.0** EMB 奖励。

题目标签