Hung Fu

아직 제출이 없습니다시간 제한2초메모리 제한256 MB

문제

The are two integer arrays aa and bb of length nn. Consider the following formula:

_i=1nmin_1jia_ib_j.\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 aa and bb.  More formally, you want to find such a permutation pp that minimizes the following function:

F(p)=_i=1nmin_1jia_p_ib_p_j.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 pp that minimizes the function.

입력

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

On the second line, you are given nn integers a_ia\_i: the elements of array aa (0a_i1,000,0000 \leq a\_i \leq 1,000,000).

On the third line, you are given nn integers b_ib\_i: the elements of array bb (0b_i1,000,0000 \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 nn integers: the lexicographically smallest permutation pp that minimizes the result of the function.