atcoder#ARC122D. [ARC122D] XOR Game

[ARC122D] XOR Game

Score : 700700 points

Problem Statement

There are 2N2N integers written on a blackboard. The ii-th integer is AiA_i.

Alice and Bob will play a game consisting of NN rounds. In each round, they do the following:

  • First, Alice chooses an integer on the blackboard and erases it. Let xx be the integer erased here.
  • Second, Bob chooses an integer on the blackboard and erases it. Let yy be the integer erased here.
  • Finally, write the value xyx \oplus y on a notebook, where \oplus denotes the bitwise XOR.

In the end, all the integers on the blackboard will be erased, and the notebook will have NN integers written on it. The greatest integer written on the notebook will be the score of the game. Alice wants to maximize this score, while Bob wants to minimize it. Find the score of the game when both players play optimally under their objectives.

Constraints

  • 1N2×1051 \leq N \leq 2 \times 10^5
  • 0Ai<2300 \leq A_i < 2^{30}
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN

A1A_1 A2A_2 \cdots A2NA_{2N}

Output

Print the answer.

2
0 1 3 5
4

Below is one possible progress of the game (it may contain suboptimal choices).

  • Round 11:
    • Alice chooses A1=0A_1=0.
    • Bob chooses A3=3A_3=3.
    • They write 03=30 \oplus 3=3 on the notebook.
  • Alice chooses A1=0A_1=0.
  • Bob chooses A3=3A_3=3.
  • They write 03=30 \oplus 3=3 on the notebook.
  • Round 22:
    • Alice chooses A4=5A_4=5.
    • Bob chooses A2=1A_2=1.
    • They write 51=45 \oplus 1=4 on the notebook.
  • Alice chooses A4=5A_4=5.
  • Bob chooses A2=1A_2=1.
  • They write 51=45 \oplus 1=4 on the notebook.
  • The score of the game is max(3,4)=4\max(3,4)=4.
2
0 0 0 0
0
10
974654030 99760550 750234695 255777344 907989127 917878091 818948631 690392797 579845317 549202360 511962375 203530861 491981716 64663831 561104719 541423175 301832976 252317904 471905694 350223945
268507123