#include <bits/stdc++.h>
using namespace std;
template <typename T>
void printvec(vector<T>& vec) {
  for (int i = 0; i < vec.size(); i++) {
    cout << vec[i] << " ";
  }
  cout << "\n";
}
struct numbertrie {
  int size;
  struct numbertrie* arr[2];
  numbertrie() {
    size = 0;
    int i;
    for (i = 0; i < 2; i++) {
      arr[i] = NULL;
    }
  }
  numbertrie(struct numbertrie* prev) {
    size = prev->size;
    int i;
    for (i = 0; i < 2; i++) {
      arr[i] = prev->arr[i];
    }
  }
  int get(string& str, int pos = 0) {
    size--;
    if (str.length() == pos) return 0;
    if (str[pos] == '1') {
      if (arr[1] != NULL && arr[1]->size != 0) {
        int temp = arr[1]->get(str, pos + 1);
        return temp;
      } else if (arr[0] != NULL && arr[0]->size != 0) {
        int temp = arr[0]->get(str, pos + 1);
        int len = str.length();
        len = len - 1 - pos;
        return temp + (1 << len);
      } else {
        abort();
      }
    } else {
      if (arr[0] != NULL && arr[0]->size != 0) {
        int temp = arr[0]->get(str, pos + 1);
        return temp;
      } else if (arr[1] != NULL && arr[1]->size != 0) {
        int temp = arr[1]->get(str, pos + 1);
        int len = str.length();
        len = len - 1 - pos;
        return temp + (1 << len);
      } else {
        abort();
      }
    }
  }
  void update(string& str, int val, int pos = 0) {
    size += val;
    if (str.length() == pos) {
      return;
    }
    if (arr[str[pos] - '0'] == NULL) {
      arr[str[pos] - '0'] = new numbertrie();
    }
    arr[str[pos] - '0']->update(str, val, pos + 1);
    return;
  }
};
string converttostring(int x) {
  int i;
  string ans;
  for (i = 0; i < 30; i++) {
    ans.push_back('0' + x % 2);
    x /= 2;
  }
  reverse(ans.begin(), ans.end());
  return ans;
}
int main() {
  std::ios::sync_with_stdio(false);
  int ttt = 1;
  while (ttt--) {
    int n, i;
    cin >> n;
    vector<int> enc(n), key(n);
    for (i = 0; i < n; i++) {
      cin >> enc[i];
    }
    for (i = 0; i < n; i++) {
      cin >> key[i];
    }
    struct numbertrie* currnum = new numbertrie();
    for (i = 0; i < n; i++) {
      string temp = converttostring(key[i]);
      currnum->update(temp, 1);
    }
    for (i = 0; i < n; i++) {
      string temp = converttostring(enc[i]);
      int ans = currnum->get(temp);
      cout << ans << " ";
    }
  }
  return 0;
}
