The are two integer arrays a and b of length n. Consider the following formula:
∑_i=1nmin_1≤j≤ia_i⊕b_j.
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)=∑_i=1nmin_1≤j≤ia_p_i⊕b_p_j.
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≤n≤50).
On the second line, you are given n integers a_i: the elements of array a (0≤a_i≤1,000,000).
On the third line, you are given n integers b_i: the elements of array b (0≤b_i≤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.