#include <cstdint>
#include <set>
#include <vector>
#include <iostream>

using i64 = long long;

class bitvector {
  using bit_type = std::uint_least64_t;
  using size_type = std::size_t;
  static constexpr size_type wordsize = 64;
  
  std::vector<bit_type> bit;
  std::vector<size_type> sum;
  
public:

  bitvector() : bit(), sum() {} 
  bitvector(const size_type size)
    : bit(size / wordsize + 1, 0), sum(size / wordsize + 1, 0) {}

  void set(const size_type i) {
    bit[i / wordsize] |= static_cast<bit_type>(1) << (i % wordsize);
  }
  void build() {
    for (size_type i = 1; i < bit.size(); i++) {
      sum[i] = sum[i - 1] + __builtin_popcountll(bit[i - 1]);
    }
  }

  size_type at(const size_type i) const {
    return bit[i / wordsize] >> (i % wordsize);
  }

  // count of ones in [0, i)
  size_type rank(const size_type i) const {
    return sum[i / wordsize]
      + __builtin_popcountll(bit[i / wordsize] & (static_cast<bit_type>(1) << (i % wordsize)) - 1);
  }

  // count of ones in [0, i)
  size_type rank(const size_type i, const size_type b) const {
    size_type ans = sum[i / wordsize]
      + __builtin_popcountll(bit[i / wordsize] & (static_cast<bit_type>(1) << (i % wordsize)) - 1);
    if(b) return ans;
    else return i - ans;
  }
};

class wavelet_matrix {
  using Integer = i64;
  using integer_type = Integer;
  using size_type = std::size_t;


  const size_type depth;
  const size_type len;
  std::vector<bitvector> mat;
  std::vector<size_type> spl;

public:

  wavelet_matrix(const std::vector<integer_type>& arr, size_type de)
    : depth(de),
      len(arr.size()),
      mat(std::vector<bitvector>(depth, bitvector(arr.size()))),
      spl(std::vector<size_type>(depth, 0)) {
        std::vector<size_type> idx(len);
        std::vector<size_type> left(len), right(len);
        for(size_type i = 0;i < len;i++) idx[i] = i;
        for(size_type d = depth; d-- > 0;) {
          size_type l = 0, r = 0;
          
          for(size_type i = 0; i < len; i++) {
            size_type k = (arr[idx[i]] >> d) & 1;
            if(k) right[r++] = idx[i], mat[d].set(i);
            else left[l++] = idx[i];
          }
          mat[d].build();
          spl[d] = l;
          swap(idx, left);
          for(size_type i = 0; i < r; i++) idx[i + l] = right[i];
        }
      }

  integer_type at(size_type i) const {
    integer_type x = static_cast<integer_type>(0);
    for(size_type d = depth; d-- > 0;) {
      size_type k = mat[d].at(i);
      x |= (static_cast<integer_type>(k) << d);
      i = mat[d].rank(i, k) + spl[d] * k;
    }
    return x;
  }

  size_type rank_x(size_type left, size_type right, integer_type x) const {
    for(size_type d = depth; d-- > 0;) {
      size_type k = ((x >> d) & 1);
      left = mat[d].rank(left, k) + spl[d] * k;
      right = mat[d].rank(right, k) + spl[d] * k;
    }
    return right - left;
  }

  integer_type quantile(size_type left, size_type right, size_type i) const {
    integer_type x = static_cast<integer_type>(0);
    for(size_type d = depth; d-- > 0;) {
      size_type cnt = mat[d].rank(right, 0) - mat[d].rank(left, 0);
      size_type k = (i < cnt) ? 0 : 1;
      x |= (k << d);
      left = mat[d].rank(left, k) + spl[d] * k;
      right = mat[d].rank(right, k) + spl[d] * k;
    }
    return x;
  }

  size_type greater_eq(size_type left, size_type right, integer_type x) const {
    size_type cnt = 0;
    for(size_type d = depth; d-- > 0;) {
      size_type k = ((x >> d) & 1);
      size_type rl = mat[d].rank(left, 1);
      size_type rr = mat[d].rank(right, 1); 
      if(k == 0) {
        cnt += rr - rl;
        left -= rl;
        right -= rr;
      }
      else {
        left = rl + spl[d];
        right = rr + spl[d];
      }
    }
    return cnt + right - left;
  }

  size_type rangefreq(size_type left, size_type right, integer_type x, integer_type y) const {
    return greater_eq(left, right, x) - greater_eq(left, right, y);
  }

  size_type greater(size_type left, size_type right, integer_type x) const {
    size_type cnt = 0;
    for(size_type d = depth; d-- > 0;) {
      size_type k = ((x >> d) & 1);
      size_type rl = mat[d].rank(left, 1);
      size_type rr = mat[d].rank(right, 1); 
      if(k == 0) {
        cnt += rr - rl;
        left -= rl;
        right -= rr;
      }
      else {
        left = rl + spl[d];
        right = rr + spl[d];
      }
    }
    return cnt;
  }
};

#include <type_traits>
#include <vector>
using i64 = long long;

template<class Iterator> class jter;
template<class Jter> class rev_jter;
template<class Jter, class F> class map_jter;
template<class Jter, class F> class filter_jter;

template<class Iterator>
class jter {

  Iterator b;
  Iterator e;

public:

  using value_type = typename Iterator::value_type;
  using difference_type = std::ptrdiff_t;
  using pointer = value_type*;
  using reference = value_type&;
  using iterator_category = std::input_iterator_tag;

  jter() {}
  jter(Iterator b, Iterator e) : b(b), e(e) {}

  void next() { b++; }
  void prev() { --e; }
  value_type& front() { return *b; }
  value_type& back() { auto c = e; return *(--c); }
  bool isnone() const { return b == e; }

  jter begin() const { return *this; }
  jter end() const { return jter(); }
  jter& operator++() { next(); return *this; }
  value_type& operator*() { return front(); }
  bool operator!=(const jter& other) const { return !isnone(); }

  rev_jter<jter<Iterator>> rev() const { return rev_jter<jter<Iterator>>(*this); }

  template<class F>
  map_jter<jter<Iterator>, F> map(F f) const { return map_jter<jter<Iterator>, F>(*this, f); }
  std::vector<value_type> tovec() const { return std::vector<value_type>(this->begin(), this->end()); }

  template<class F>
  filter_jter<jter<Iterator>, F> filter(F f) const { return filter_jter<jter<Iterator>, F>(*this, f); }
  
  template<class R, class F>
  R sum(R init, F f) const {
    for(const auto& x: *this) init = f(init, x);
    return init;
  }


};

template<class Jter>
class rev_jter {

  Jter j;

public:

  using value_type = typename Jter::value_type;
  using difference_type = std::ptrdiff_t;
  using pointer = value_type*;
  using reference = value_type&;
  using iterator_category = std::input_iterator_tag;

  rev_jter() {}
  rev_jter(Jter j): j(j) {}

  void next() { j.prev(); }
  void prev() { j.next(); }
  value_type& front() { return j.back(); }
  value_type& back() { return j.front(); }
  bool isnone() const { return j.isnone(); }

  rev_jter begin() const { return *this; }
  rev_jter end() const { return rev_jter(); }
  rev_jter& operator++() { next(); return *this; }
  value_type& operator*() { return front(); }
  bool operator!=(const rev_jter& other) const { return !isnone(); }

  Jter rev() const { return j; }
  template<class F>
  map_jter<rev_jter, F> map(F f) const { return map_jter<rev_jter, F>(*this, f); }
  template<class R, class F>
  R sum(R init, F f) const {
    for(const auto& x: *this) init = f(init, x);
    return init;
  }
};

template<class Jter, class MapF>
class map_jter {

  
  using map_function = MapF;

  Jter j;
  union _u {
    map_function f;
    bool isend;
    _u(): isend(true) {} 
    _u(MapF f): f(f) {}
  } u;

public:

  using value_type = decltype(std::declval<map_function>()(std::declval<typename Jter::value_type>()));
  using difference_type = std::ptrdiff_t;
  using pointer = value_type*;
  using reference = value_type&;
  using iterator_category = std::input_iterator_tag;

  map_jter() {}
  map_jter(Jter j, map_function f): j(j), u(f) {}

  void next() { j.next(); }
  void prev() { j.prev(); }
  value_type front() { return u.f(j.front()); }
  value_type back() { return u.f(j.back()); }
  bool isnone() const { return j.isnone(); }

  map_jter begin() const { return *this; }
  map_jter end() const { return map_jter(); }
  map_jter& operator++() { next(); return *this; }
  value_type operator*() { return front(); }
  bool operator!=(const map_jter& other) const { return !isnone(); }

  Jter rev() const { return j; }

  template<class G>
  map_jter<map_jter, G> map(G g) const { return map_jter<map_jter, G>(*this, g); }

  template<class G>
  filter_jter<map_jter, G> map(G g) const { return filter_jter<map_jter, G>(*this, g); }

  std::vector<value_type> tovec() const { return std::vector<value_type>(this->begin(), this->end()); }

  template<class R, class G>
  R sum(R init, G g) const {
    for(const auto& x: *this) init = g(init, x);
    return init;
  }
};

template<class Jter, class FilterF>
class filter_jter {

  using filter_function = FilterF;

  Jter j;
  union _u {
    filter_function f;
    bool isend;
    _u(): isend(true) {}
    _u(filter_function f): f(f) {}
  } u;

  //static_assert(std::is_same<decltype(std::declval<filter_function>()(std::declval<typename Jter::value_type>())), bool>::value, "function for filter must retuen boolern");

public:

  using value_type = typename Jter::value_type;
  using difference_type = std::ptrdiff_t;
  using pointer = value_type*;
  using reference = value_type&;
  using iterator_category = std::input_iterator_tag;

  filter_jter() {}
  filter_jter(Jter _j, filter_function f): j(_j), u(f) {
    while(!j.isnone() && !u.f(j.front())) j.next();
    while(!j.isnone() && !u.f(j.back())) j.prev();
  }

  void next() {
    while(!j.isnone() && (j.next(), !u.f(j.front())));
  }
  void prev() {
    while(!j.isnone() && (j.prev(), !u.f(j.back())));
  }
  value_type front() { return j.front(); }
  value_type back() { return j.back(); }
  bool isnone() const { return j.isnone(); }

  filter_jter begin() const { return *this; }
  filter_jter end() const { return filter_jter(); }
  filter_jter& operator++() { next(); return *this; }
  value_type operator*() { return front(); }
  bool operator!=(const filter_jter& other) const { return !isnone(); }

  Jter rev() const { return j; }

  template<class G>
  map_jter<filter_jter, G> map(G g) const { return map_jter<filter_jter, G>(*this, g); }

  template<class G>
  filter_jter<filter_jter, G> map(G g) const { return filter_jter<filter_jter, G>(*this, g); }

  std::vector<value_type> tovec() const { return std::vector<value_type>(this->begin(), this->end()); }

  template<class R, class G>
  R sum(R init, G g) const {
    for(const auto& x: *this) init = g(init, x);
    return init;
  }
};

class range {

  i64 b;
  i64 e;

public:

  using value_type = i64;
  using difference_type = std::ptrdiff_t;
  using pointer = value_type*;
  using reference = value_type&;
  using iterator_category = std::input_iterator_tag;

  range() {}
  range(i64 n) : b(0), e(n) {}
  range(i64 b, i64 e) : b(b), e(e) {}

  value_type next() { return b++; }
  value_type prev() { return --e; }
  value_type front() { return b; }
  value_type back() { return e - 1; }
  bool isnone() const { return b == e; }

  range begin() const { return *this; }
  range end() const { return range(); }
  range& operator++() { next(); return *this; }
  value_type operator*() { return front(); }
  bool operator!=(const range& other) const { return !isnone(); }

  rev_jter<range> rev() const { return rev_jter<range>(*this); }

  template<class F>
  map_jter<range, F> map(F f) const { return map_jter<range, F>(*this, f); }

  template<class F>
  filter_jter<range, F> filter(F f) const { return filter_jter<range, F>(*this, f); }

  std::vector<value_type> tovec() const { return std::vector<value_type>(this->begin(), this->end()); }
  template<class R, class F>
  R sum(R init, F f) const {
    for(const auto& x: *this) init = f(init, x);
    return init;
  }
};

template<class Iterator>
jter<Iterator> jtr(Iterator b, Iterator e) { return jter<Iterator>(b, e); }

template<class V>
jter<typename V::iterator> jtr(V& v) { return jter<typename V::iterator>(begin(v), end(v)); }

template<class V>
jter<typename V::const_iterator> cjtr(const V& v) { return jter<typename V::const_iterator>(cbegin(v), cend(v)); }



#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T, class Arg = i64>
T input(Arg dummy = Arg()) { T t; cin >> t; return t; }

/*
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(nullptr);
  //cout << range(5).sum(0, [](i64 x, i64 y) { return x + y; }) << endl;

  //cout << range(5).map(input<i64>).sum(0, [](i64 x, i64 y) { return x + y; }) << endl;

  for(auto x: range(10).filter([](i64 x) { return x % 2 == 1; }))  {
    cout << x << endl;
  }
}
*/


int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(nullptr);

  const i64 n = input<i64>();
  auto a = range(n).map(input<i64>).tovec();
  auto b = range(n).map(input<i64>).tovec();

  i64 ans = 0;

  if(n & 1) {
    ans = jtr(a).sum(ans, [](i64 x, i64 y) { return x ^ y; });
    ans = jtr(b).sum(ans, [](i64 x, i64 y) { return x ^ y; });
  }

  for(i64 i: range(28)) {
    i64 bit = 1 << (i + 1);

    wavelet_matrix wm(
        jtr(b).map([bit](i64 x) { return x & (bit - 1); }).tovec(),
        i + 1
        );

    ans = jtr(a)
      .filter([&](i64 x) { return wm.greater(0, n, ~x&(bit - 1)) & 1; })
      .sum(ans, [bit](i64 x, i64 y) { return x ^ bit; } );
  }

  cout << ans << endl;
}


Measured memory_bytes: 14160