#include <bits/stdc++.h>
#define int long long
using namespace std;
const int maxn = 1e5 + 7;
const int maxlog = 60;
vector<pair<int, int>> g[maxn];
int h[maxn];
void dfs(int u, int xorr, int par)
{
    h[u] = xorr;
    for (auto x : g[u])
    {
        if (x.first == par)
            continue;
        dfs(x.first, xorr ^ x.second, u);
    }
    return;
}

signed main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n - 1; i++)
    {
        int a, b, w;
        cin >> a >> b >> w;
        g[a].push_back({b, w});
        g[b].push_back({a, w});
    }
    dfs(1, 0, -1);
    unordered_set<int> s;
    for (int i = 1; i <= n; i++)
    {
        s.insert(h[i]);
    }
    vector<int> v;
    for (auto x : s)
        v.push_back(x);
    int maxi = 0;
    for (int i = 0; i < v.size(); i++)
    {
        for (int j = i + 1; j < v.size(); j++)
        {
            maxi = max(maxi, v[i] ^ v[j]);
        }
    }
    cout << maxi << endl;
    return 0;
}
