#include <bits/stdc++.h>

#define ll long long

using namespace std;

struct trie_node {
    int v;
    trie_node* c[2];

    trie_node(){
        v = 0;
        c[0] = c[1] = NULL;
    }
};

void insert(trie_node* r, int x) {
    trie_node* it = r;
    for(int i=31;i>=0;i--) {
        bool v = x & (1<<i);
        if(it->c[v] == NULL)
            it->c[v] = new trie_node();
        it = it->c[v];
    }
    it->v = x;
}

int query(trie_node* r, int x) {
    trie_node* it = r;
    for(int i=31;i>=0;i--) {
        bool v = x & (1<<i);
        if(it->c[1-v] != NULL)
            it = it->c[1-v];
        else if(it->c[v] != NULL)
            it = it->c[v];
    }
    return x^it->v;
}

int a[200000], b[200000];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n; cin >> n;
    bool b1 = true, a1 = true;
    for(int i=0;i<n;i++) cin >> a[i], a1 = a1 && a[i] == 1;
    for(int i=0;i<n;i++) cin >> b[i], b1 = b1 && b[i] == 1;
    if(b1) {
        trie_node* t = new trie_node();
        insert(t, 0);
        int x=0;
        x^=a[0];
        insert(t,x);
        int r=query(t, x);
        for(int i=1;i<n;i++){
            x^=a[i];
            insert(t,x);
            r=max(r,query(t,x));
        }
        cout << r << '\n';
    }
    else if(a1) {
        cout << *max_element(b,b+n) << '\n';
    }
    return 0;
}