#include <iostream>
#include <vector>
#include <unordered_set>
#include <set>
#define endl '\n'

using namespace std;

long long dist[100005];
int n;
vector<pair<int,long long>> v[100005];

void dfs(int i, int par) {
    for(auto &x : v[i]) {
        if(x.first==par) continue;
        dist[x.first]=dist[i]^x.second;
        dfs(x.first, i);
    }
}

int main() {
    cin >> n;
    for(int i = 1; i <= n-1; i++) {
        int a,b; long long w; cin >> a >> b >> w;
        v[a].push_back({b, w});
        v[b].push_back({a, w});
    }
    dfs(1, -1);

    set<long long> vals;
    for(int i = 1; i <= n; i++) vals.insert(dist[i]);
    vector<long long> vals2;
    for(auto &x : vals) vals2.push_back(x);

    long long ans=0;
    for(int i = 0; i < vals2.size(); i++) {
        for(int j = 0; j < i; j++) {
            ans=max(ans, vals2[i]^vals2[j]);
        }
    }
    cout<<ans;
}