#include <bits/stdc++.h>

using namespace std;

#define int long long
//#define double long double

int n;
int a[200010];
int b[200010];

int mysolution(){
    int result = 0;
    vector<int> c[30];
    for(int j = 0; j < n; j++){
        int pref = 0;
        for(int i = 0; i < 30; i++){
            if(b[j] & (1 << i)) pref ^= (1 << i);
            c[i].push_back(pref);
        }
    }
    for(int i = 0; i < 30; i++) sort(c[i].begin(), c[i].end());
    for(int i = 0; i < 17; i++){
        vector<int> newp;
        for(int j = 0; j < n; j++){
            if(newp.empty() || newp.back() != c[i][j]) newp.push_back(c[i][j]);
            else newp.pop_back();
        }
        c[i] = newp;
    }
    for(int j = 0; j < n; j++){
        int curpref = 0;
        for(int i = 0; i < 30; i++){
            if(a[j] & (1 << i)) curpref ^= (1 << i);
            int low, high;
            if(a[j] & (1 << i)){
                low = 0, high = (1 << (i + 1)) - curpref - 1;
            }
            else{
                high = (1 << (i + 1)) - curpref - 1;
                low = (1 << i) - curpref;
            }
            int lo = 0, hi = (int)c[i].size();
            while(lo != hi){
                int mi = (lo + hi) >> 1;
                if(c[i][mi] < low) lo = mi + 1;
                else hi = mi;
            }
            if(lo == (int)c[i].size()) continue;
            int l = lo;
            lo = -1, hi = (int)c[i].size() - 1;
            while(lo != hi){
                int mi = (lo + hi + 1) >> 1;
                if(c[i][mi] > high) hi = mi - 1;
                else lo = mi;
            }
            int r = hi;
            int c1 = r - l + 1;
            if(c1 & 1) result ^= (1 << i);
            ////
            high = (1 << (i + 1)) - 1;
            if(a[j] & (1 << i)){
                low = (1 << (i + 1)) - curpref + (1 << i);
                int lo = 0, hi = (int)c[i].size();
                while(lo != hi){
                    int mi = (lo + hi) >> 1;
                    if(c[i][mi] < low) lo = mi + 1;
                    else hi = mi;
                }
                if(lo == (int)c[i].size()) continue;
                int l = lo;
                lo = -1, hi = (int)c[i].size() - 1;
                while(lo != hi){
                    int mi = (lo + hi + 1) >> 1;
                    if(c[i][mi] > high) hi = mi - 1;
                    else lo = mi;
                }
                int r = hi;
                int c1 = r - l + 1;
                if(c1 & 1) result ^= (1 << i);
            }
        }
        //cout << result << endl;
    }
    return result;
}

int bad(){
    int result = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            result ^= (a[i] + b[j]);
        }
    }
    return result;
}

mt19937 mt(123);
void gen(int my){
    if(my){
        cin >> n;
        for(int i = 0; i < n; i++) cin >> a[i];
        for(int i = 0; i < n; i++) cin >> b[i];
    }
    else{
        n = 200000;
        for(int i = 0; i < n; i++) a[i] = mt() % (1 << 28);
        for(int i = 0; i < n; i++) b[i] = mt() % (1 << 28);
    }
}

main()
{
    ios_base::sync_with_stdio(0);
    if(0){
        for(int cnt = 1; ; cnt++){
            gen(0);
            int a1 = bad();
            int a2 = mysolution();
            if(a1 != a2){
                cout << n << endl;
                for(int i = 0; i < n; i++) cout << a[i] << ' '; cout << endl;
                for(int i = 0; i < n; i++) cout << b[i] << ' '; cout << endl;
                cout << "EXPECTED: " << a1 << endl;
                cout << "FOUND: " << a2 << endl;
                exit(0);
            }
            if(cnt % 1024 == 0) cout << cnt << " OK" << endl;
        }
    }
    else{
        gen(1);
        cout << mysolution() << endl;
    }
}


Measured memory_bytes: 56832