#include <bits/stdc++.h>
#define N 200005
#define MAXK 600005
#define MOD 998244353
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int>
#define ll long long
using namespace std;

ll a[N], b[N];

struct cvor{
    cvor* deca[2]={nullptr, nullptr};
};

void dodaj(cvor* koren, ll x)
{
    cvor* kor = koren;
    for(int i = 31; i>=0; i--)
    {
        int b = (x&(1LL<<i))!=0;
        if(!(kor->deca[b]))kor->deca[b]= new cvor();
        kor = kor->deca[b];
    }
}

ll nadji(cvor* koren, ll x)
{
    cvor* kor = koren;
    ll ans = 0;
    for(int i = 31; i>=0; i--)
    {
        int b = (x& (1LL<<i))!=0;
        if(kor->deca[!b])
        {
            ans |= (1LL<<i);
            kor = kor->deca[!b];
        }else kor = kor->deca[b];
    }
    return ans;
}

void solve()
{
    int n; cin>>n;
    for(int i = 0; i<n; i++)cin>>a[i];
    for(int i = 0; i<n; i++)cin>>b[i];

    cvor* koren = new cvor();
    dodaj(koren, 0);

    ll ans = -1;
    for(int i = 0; i<n; i++)
    {
        ans = max(ans, nadji(koren, a[i]));
        dodaj(koren, a[i]);
    }

    cout<<ans<<"\n";


}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    //int t;cin>>t;
    int t = 1;
    while (t--) {
        solve();
    }

    return 0;
}