#include <bits/stdc++.h>
using namespace std;
struct Node {
  int flag;
  int sum;
  Node *edge[2];
  Node() {
    flag = 0;
    sum = 0;
    for (int i = 0; i < 2; i++) edge[i] = NULL;
  }
};
Node root;
Node *v = &root;
long long pr[31];
vector<long long> a;
int main() {
  long long i, q, x, y, j, res = 0, ans, pos, cur;
  char type;
  pr[0] = 1;
  for (i = 1; i < 31; i++) pr[i] = pr[i - 1] << 1;
  cin >> q;
  for (i = 0; i < q; i++) {
    cin >> x;
    a.push_back(x);
  }
  for (i = 0; i < q; i++) {
    cin >> x;
    type = '+';
    if (type == '+') {
      y = x;
      vector<bool> b;
      while (y) {
        b.push_back(y % 2);
        y >>= 1;
      }
      while (b.size() < 30) b.push_back(false);
      reverse(b.begin(), b.end());
      v = &root;
      for (j = 0; j < b.size(); j++) {
        if (!v->edge[b[j]]) v->edge[b[j]] = new Node();
        v->sum++;
        v = v->edge[b[j]];
      }
      v->flag++;
      v->sum++;
    }
  }
  for (i = 0; i < q; i++) {
    type = '?';
    x = a[i];
    ans = 1e18;
    cur = 0;
    if (type == '?') {
      y = x;
      vector<bool> b;
      while (y) {
        b.push_back(y % 2);
        y >>= 1;
      }
      while (b.size() < 30) b.push_back(false);
      reverse(b.begin(), b.end());
      v = &root;
      res = a[i];
      for (j = 0; j < b.size(); j++) {
        if (v->flag) {
          if (ans > res) {
            ans = res;
            pos = cur;
          }
        }
        if (v->edge[b[j]] && v->edge[b[j]]->sum > 0) {
          if (b[j]) {
            res -= pr[29 - j];
            cur += pr[29 - j];
          }
          v = v->edge[b[j]];
        } else {
          if (v->edge[1 - b[j]] && v->edge[1 - b[j]]->sum > 0) {
            v = v->edge[1 - b[j]];
            if (1 - b[j]) cur += pr[29 - j];
          } else
            break;
        }
      }
      if (v->flag) {
        if (ans > res) {
          ans = res;
          pos = cur;
        }
      }
      cout << (a[i] ^ pos) << ' ';
      y = pos;
      b.resize(0);
      while (y) {
        b.push_back(y % 2);
        y >>= 1;
      }
      while (b.size() < 30) b.push_back(false);
      reverse(b.begin(), b.end());
      v = &root;
      for (j = 0; j < b.size(); j++) {
        v->sum--;
        v = v->edge[b[j]];
      }
      v->sum--;
      v->flag--;
    }
  }
}
