#include <bits/stdc++.h>   using namespace std;   int to1[1000010], w[1000010], begin1[1000010], next1[1000010], v[1000010],       p[1000010], d[1000010], e;   void add(int x, int y, int z) {     to1[++e] = y;     next1[e] = begin1[x];     begin1[x] = e;     w[e] = z;   }   void ins(int x) {     int i;     for (i = 30; i >= 0; i--)       if ((x >> i) & 1) {         if (!p[i]) {           p[i] = x;           break;         }         x ^= p[i];       }   }   void dfs(int x, int now) {     int i;     d[x] = now;     v[x] = 1;     for (i = begin1[x]; i; i = next1[i]) {       if (!v[to1[i]])         dfs(to1[i], now ^ w[i]);       else         ins(now ^ w[i] ^ d[to1[i]]);     }   }   int find(int x) {     int i;     for (i = 30; i >= 0; i--)       if ((p[i] ^ x) < x) x = p[i] ^ x;     return x;   }   int main() {     int i, u, v, w, n, m;     scanf( %d%d , &n, &m);     for (i = 1; i <= m; i++) {       scanf( %d%d%d , &u, &v, &w);       add(u, v, w);       add(v, u, w);     }     dfs(1, 0);     printf( %d n , find(d[n]));   }   