Alice has a very important message *M* consisting of some non-negative integers that she wants to keep secret from Eve. Alice knows that the only theoretically secure cipher is one-time pad. Alice generates a random key *K* of the length equal to the message's length. Alice computes the bitwise xor of each element of the message and the key (<img align="middle" class="tex-formula" src="https://espresso.codeforces.com/0c01d57961927bc12eb51d8197470990daaaa8de.png" style="max-width: 100.0%;max-height: 100.0%;"/>, where <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/c4b7092c0f7ce6535f2574569c98f7b3c2fe2c5f.png" style="max-width: 100.0%;max-height: 100.0%;"/> denotes the [bitwise XOR operation](https://en.wikipedia.org/wiki/Bitwise_operation#XOR)) and stores this encrypted message *A*. Alice is smart. Be like Alice.

For example, Alice may have wanted to store a message *M* = (0, 15, 9, 18). She generated a key *K* = (16, 7, 6, 3). The encrypted message is thus *A* = (16, 8, 15, 17).

Alice realised that she cannot store the key with the encrypted message. Alice sent her key *K* to Bob and deleted her own copy. Alice is smart. Really, be like Alice.

Bob realised that the encrypted message is only secure as long as the key is secret. Bob thus randomly permuted the key before storing it. Bob thinks that this way, even if Eve gets both the encrypted message and the key, she will not be able to read the message. Bob is not smart. Don't be like Bob.

In the above example, Bob may have, for instance, selected a permutation (3, 4, 1, 2) and stored the permuted key *P* = (6, 3, 16, 7).

One year has passed and Alice wants to decrypt her message. Only now Bob has realised that this is impossible. As he has permuted the key randomly, the message is lost forever. Did we mention that Bob isn't smart?

Bob wants to salvage at least some information from the message. Since he is not so smart, he asks for your help. You know the encrypted message *A* and the permuted key *P*. What is the lexicographically smallest message that could have resulted in the given encrypted text?

More precisely, for given *A* and *P*, find the lexicographically smallest message *O*, for which there exists a permutation π such that <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/a13e05dbed3e9a47b9d8d6d0f07297a940549234.png" style="max-width: 100.0%;max-height: 100.0%;"/> for every *i*.

Note that the sequence *S* is lexicographically smaller than the sequence *T*, if there is an index *i* such that *S*<sub class="lower-index">*i*</sub> &lt; *T*<sub class="lower-index">*i*</sub> and for all *j* &lt; *i* the condition *S*<sub class="lower-index">*j*</sub> = *T*<sub class="lower-index">*j*</sub> holds.
The first line contains a single integer *N* (1 ≤ *N* ≤ 300000), the length of the message. 

The second line contains *N* integers *A*<sub class="lower-index">1</sub>, *A*<sub class="lower-index">2</sub>, ..., *A*<sub class="lower-index">*N*</sub> (0 ≤ *A*<sub class="lower-index">*i*</sub> &lt; 2<sup class="upper-index">30</sup>) representing the encrypted message.

The third line contains *N* integers *P*<sub class="lower-index">1</sub>, *P*<sub class="lower-index">2</sub>, ..., *P*<sub class="lower-index">*N*</sub> (0 ≤ *P*<sub class="lower-index">*i*</sub> &lt; 2<sup class="upper-index">30</sup>) representing the permuted encryption key.
In the first case, the solution is (10, 3, 28), since <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/a896b30a69636d1bfbfa981eae10650f5fee843c.png" style="max-width: 100.0%;max-height: 100.0%;"/>, <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/e383e4333ea37c4652ce2ac1ccfc2cfcf96e0896.png" style="max-width: 100.0%;max-height: 100.0%;"/> and <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/c24ed3c6f88805eb3710487b3fe07ff64034151a.png" style="max-width: 100.0%;max-height: 100.0%;"/>. Other possible permutations of key yield messages (25, 6, 10), (25, 3, 15), (10, 21, 10), (15, 21, 15) and (15, 6, 28), which are all lexicographically larger than the solution.
3
8 4 13
17 2 7
10 3 28
5
12 7 87 22 11
18 39 9 12 16
0 14 69 6 44
10
331415699 278745619 998190004 423175621 42983144 166555524 843586353 802130100 337889448 685310951
226011312 266003835 342809544 504667531 529814910 684873393 817026985 844010788 993949858 1031395667
128965467 243912600 4281110 112029883 223689619 76924724 429589 119397893 613490433 362863284
5
134 246 57 176 239
14 83 97 175 187
41 77 55 209 188
10
241 187 20 18 151 144 238 193 86 63
18 69 86 91 111 118 124 172 227 253
12 23 6 68 116 203 129 132 32 67
4
0 0 0 0
0 0 0 0
0 0 0 0
4
5 5 3 3
5 3 3 7
0 2 0 0
from itertools import permutations
from math import inf
n=int(input())
a = input()
a = [int(i) for i in a.split()]
l = input()
l = [int(i) for i in l.split()]
vis = [i for i in range(n)]
ans = []
temp  =  inf
temp2 = 0

for i in range(n) :
    f =  0
    temp = inf
    for j in range(len(vis)) :
        temp2 = temp
        
        temp = min(temp , l[vis[j]]^a[i])
        if temp!=temp2:
            f = j
    ans.append(temp)
    del vis[f]
print(*ans)
        
    
