시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 256 MB228840.000%

문제

The are two integer arrays $a$ and $b$ of length $n$. Consider the following formula:

$$\sum\limits_{i=1}^{n} \min\limits_{1 \leq j \leq i} a_i \oplus b_j\text{.}$$

You are practicing the calculation of the result of the above formula, and you have noticed that the order of elements in the arrays matters. Now you want to minimize the result of the calculation by permuting the elements of arrays $a$ and $b$.  More formally, you want to find such a permutation $p$ that minimizes the following function:

$$F(p) = \sum\limits_{i=1}^{n} \min\limits_{1 \leq j \leq i} a_{p_i} \oplus b_{p_j}\text{.}$$

Find and output the lexicographically smallest permutation $p$ that minimizes the function.

입력

On the first line, you are given a single integer $n$: the size of arrays ($1 \leq n \leq 50$).

On the second line, you are given $n$ integers $a_i$: the elements of array $a$ ($0 \leq a_i \leq 1,000,000$).

On the third line, you are given $n$ integers $b_i$: the elements of array $b$ ($0 \leq b_i \leq 1,000,000$).

출력

On the first line, output a single integer: the minimum possible result of the function. On the second line, output $n$ integers: the lexicographically smallest permutation $p$ that minimizes the result of the function.

예제 입력 1

3
1 2 3
3 2 1

예제 출력 1

1
2 3 1