#d2809. 最后的舞会

最后的舞会

The Last Dance

Problem Description

The teacher is throwing a farewell dance for the graduating students. 2N2N students will attend and be paired into NN dancing couples. Each student has a number; if student ii is paired with student jj, the satisfaction of that couple is Ai,jA_{i,j} (for i<ji < j). The satisfaction of the whole ball is defined as the XOR sum of the satisfaction of every couple: after the students are split into NN groups, with the ii-th couple having satisfaction AiA_i, the ball's satisfaction is A1⊕A2⊕⋯⊕ANA_1 \oplus A_2 \oplus \dots \oplus A_N.

Find the maximum possible satisfaction of the ball.

Input Format

The first line gives NN: there are 2N2N students at the dance.

Then follows a matrix giving the satisfaction when ii and jj are paired:

A_{1,2}, A_{1,3}, ... A_{1,2N}
A_{2,3}, ... A_{2,2N}
...
A_{2N-1,2N}

where 1≤N≤81 \le N \le 8 and 0≤Ai,j≤2300 \le A_{i,j} \le 2^{30}.

Output Format

Output the maximum possible satisfaction of the ball.

Sample Input

2
4 0 1
5 3
2

Sample Output

6

Sample Explanation

  • If {1,2},{3,4}\{1,2\}, \{3,4\}: $\mathit{ans} = A_{1,2} \oplus A_{3,4} = 4 \oplus 2 = 6$
  • If {1,3},{2,4}\{1,3\}, \{2,4\}: $\mathit{ans} = A_{1,3} \oplus A_{2,4} = 0 \oplus 3 = 3$
  • If {1,4},{2,3}\{1,4\}, \{2,3\}: $\mathit{ans} = A_{1,4} \oplus A_{2,3} = 1 \oplus 5 = 4$

The answer is max⁡(6,3,4)=6\max(6, 3, 4) = 6.