#include <bits/stdc++.h>
#define int long long
using namespace std;
const int maxn = 1e5 + 7;
const int maxlog = 60;
int pref[maxn];
signed main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n - 1; i++)
    {
        int a, b, w;
        cin >> a >> b >> w;
        pref[b] = pref[a] ^ w;
    }

    unordered_set<int> s;
    for (int i = 1; i <= n; i++)
    {
        s.insert(pref[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;
}
