#include <bits/stdc++.h>
#define int long long
using namespace std;
const int maxn = 1e5 + 7;
vector<pair<int, int>> g[maxn];
int maxi = 0;
void dfs(int u, int xorr, int par)
{
    maxi = max(maxi, 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});
    }
    for (int i = 1; i <= n; i++)
    {
        dfs(i, 0, -1);
    }
    cout << maxi << endl;
    return 0;
}
