#d2926. 字典序最小的异或数组

字典序最小的异或数组

Lexicographically Smallest XOR Array

Problem Description

You are given two arrays {A}\{A\} and {B}\{B\}, both of length NN. You may rearrange the order of array {B}\{B\} arbitrarily, and define

Xi=Ai⊕Bi,i=1,2,…,N.X_i = A_i \oplus B_i, \quad i = 1, 2, \dots, N.

Find, among all possible arrays {X}\{X\}, the lexicographically smallest one.

Input Format

The first line contains an integer NN.

The second line contains NN space-separated integers, the array {A}\{A\}.

The third line contains NN space-separated integers, the array {B}\{B\}.

Output Format

Output one line of NN space-separated integers — the lexicographically smallest {X}\{X\}.

Sample Input 1

3
520 1314 61
1389 104 577

Sample Output 1

73 79 85

Sample Input 2

3
8 4 13
17 2 7

Sample Output 2

10 3 28

Sample Input 3

3
0 0 0
17 2 7

Sample Output 3

2 7 17

Constraints

  • 1≤N≤2×1031 \le N \le 2 \times 10^3
  • 0≤Ai,Bi<2300 \le A_i, B_i < 2^{30}

Hint

It is obvious that Xi≥0X_i \ge 0.