#include <bits/stdc++.h>
using namespace std;
struct Node {
  long long bit;
  long long minn;
  long long count;
  Node *zero, *one;
  Node(long long bit) : bit(bit) {
    minn = 1000000000000000000ll;
    zero = 0;
    one = 0;
    count = 0;
  }
  void set(long long v, long long delta) {
    count += delta;
    if (bit >= 0) {
      long long val = v & (1ll << bit);
      minn = 1000000000000000000ll;
      if (val) {
        if (one == 0) one = new Node(bit - 1);
        one->set(v, delta);
      } else {
        if (zero == 0) zero = new Node(bit - 1);
        zero->set(v, delta);
      }
      if (one != 0) minn = min(minn, one->minn);
      if (zero != 0) minn = min(minn, zero->minn);
    } else {
      if (count > 0)
        minn = v;
      else
        minn = 1000000000000000000ll;
    }
  }
  long long query(long long mask) {
    if (bit >= 0) {
      long long val = mask & (1ll << bit);
      long long minn2 = 1000000000000000000ll;
      if (val and one and one->count) {
        minn2 = min(minn2, one->query(mask) ^ val);
      } else if (!val and zero and zero->count) {
        minn2 = min(minn2, zero->query(mask) ^ val);
      } else {
        if (one != 0 and one->count) minn2 = min(minn2, one->query(mask) ^ val);
        if (zero != 0 and zero->count)
          minn2 = min(minn2, zero->query(mask) ^ val);
      }
      return minn2;
    } else {
      return minn;
    }
  }
  void insert(long long v) { set(v, 1); }
  void remove(long long v) { set(v, -1); }
};
Node *T;
long long M[500000], P[500000];
int main() {
  std::ios::sync_with_stdio(false);
  long long N;
  while (cin >> N) {
    T = new Node(35);
    for (long long i = 0; i < N; i++) cin >> M[i];
    for (long long i = 0; i < N; i++) {
      cin >> P[i];
      T->insert(P[i]);
    }
    for (long long i = 0; i < N; i++) {
      long long val = T->query(M[i]);
      T->remove(M[i] ^ val);
      cout << (i > 0 ? " " : "") << val;
    }
    cout << endl;
  }
}
