#include <bits/stdc++.h>
using namespace std;
void fr(long long &a, bool f = 0, char ch = getchar()) {
  for (a = 0; ch < '0' || ch > '9'; ch = getchar()) ch == '-' ? f = 1 : 0;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) a = a * 10 + ch - '0';
  a = f ? -a : a;
}
long long fr() {
  long long a;
  return fr(a), a;
}
const long long N = 1e5, M = 1e5, S = 60;
long long n, m, val[N + 10];
bool vis[N + 10];
namespace Basis {
long long cnt;
long long d[S + 10], p[S + 10];
bool zero;
bool insert(long long x) {
  for (long long i = S; ~i; i--)
    if (x & (1ll << i)) {
      if (p[i] == 0)
        return p[i] = x, cnt++, 1;
      else
        x ^= p[i];
    }
  if (x == 0) zero = 1;
  return 0;
}
long long maxXor(long long ret) {
  for (long long i = S; ~i; i--)
    if ((ret ^ p[i]) > ret) ret ^= p[i];
  return ret;
}
long long minXor(long long ret) {
  for (long long i = S; ~i; i--)
    if ((ret ^ p[i]) < ret) ret ^= p[i];
  return ret;
}
void rebuild() {
  cnt = 0;
  for (long long i = S; ~i; i--)
    for (long long j = i - 1; ~j; j--)
      if (p[i] & (1ll << j)) p[i] ^= p[j];
  for (long long i = 0; i <= S; i++)
    if (p[i]) d[++cnt] = p[i];
}
long long kth(long long k) {
  if (zero) k--;
  if (k >= (1ll << cnt)) return -1;
  long long ret = 0;
  for (long long i = S; ~i; i--)
    if (k & (1ll << i)) ret ^= p[i];
  return ret;
}
}  // namespace Basis
using namespace Basis;
namespace Edges {
struct Edge {
  long long to, nxt, val;
} e[(M << 1) + 10];
long long etot, hd[N + 10];
void adde(long long x, long long y, long long z) {
  e[++etot] = {y, hd[x], z}, hd[x] = etot;
}
}  // namespace Edges
using namespace Edges;
void dfs(long long u, long long p, long long Val) {
  vis[u] = 1, val[u] = Val;
  for (long long i = hd[u]; i; i = e[i].nxt) {
    long long v = e[i].to;
    if (v == p) continue;
    if (vis[v])
      insert(val[u] ^ val[v] ^ e[i].val);
    else
      dfs(v, u, val[u] ^ e[i].val);
  }
}
struct OI {
  long long RP, score;
} FJOI2021;
signed main() {
  FJOI2021.RP++, FJOI2021.score++, 392699;
  fr(n), fr(m);
  for (long long i = 1, x, y, z; i <= m; i++)
    fr(x), fr(y), fr(z), adde(x, y, z), adde(y, x, z);
  return dfs(1, 0, 0), printf("%lld\n", minXor(val[n])), 0;
}

### Prompt

Please formulate a cpp solution to the following problem:

You are given an undirected graph with weighted edges. The length of some path between two vertices is the bitwise xor of weights of all edges belonging to this path (if some edge is traversed more than once, then it is included in bitwise xor the same number of times). You have to find the minimum length of path between vertex 1 and vertex n.

Note that graph can contain multiple edges and loops. It is guaranteed that the graph is connected.

Input

The first line contains two numbers n and m (1 ≤ n ≤ 100000, n - 1 ≤ m ≤ 100000) — the number of vertices and the number of edges, respectively.

Then m lines follow, each line containing three integer numbers x, y and w (1 ≤ x, y ≤ n, 0 ≤ w ≤ 108). These numbers denote an edge that connects vertices x and y and has weight w.

Output

Print one number — the minimum length of path between vertices 1 and n.

Examples

Input

3 3
1 2 3
1 3 2
3 2 0


Output

2


Input

2 2
1 1 3
1 2 3


Output

0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void fr(long long &a, bool f = 0, char ch = getchar()) {
  for (a = 0; ch < '0' || ch > '9'; ch = getchar()) ch == '-' ? f = 1 : 0;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) a = a * 10 + ch - '0';
  a = f ? -a : a;
}
long long fr() {
  long long a;
  return fr(a), a;
}
const long long N = 1e5, M = 1e5, S = 60;
long long n, m, val[N + 10];
bool vis[N + 10];
namespace Basis {
long long cnt;
long long d[S + 10], p[S + 10];
bool zero;
bool insert(long long x) {
  for (long long i = S; ~i; i--)
    if (x & (1ll << i)) {
      if (p[i] == 0)
        return p[i] = x, cnt++, 1;
      else
        x ^= p[i];
    }
  if (x == 0) zero = 1;
  return 0;
}
long long maxXor(long long ret) {
  for (long long i = S; ~i; i--)
    if ((ret ^ p[i]) > ret) ret ^= p[i];
  return ret;
}
long long minXor(long long ret) {
  for (long long i = S; ~i; i--)
    if ((ret ^ p[i]) < ret) ret ^= p[i];
  return ret;
}
void rebuild() {
  cnt = 0;
  for (long long i = S; ~i; i--)
    for (long long j = i - 1; ~j; j--)
      if (p[i] & (1ll << j)) p[i] ^= p[j];
  for (long long i = 0; i <= S; i++)
    if (p[i]) d[++cnt] = p[i];
}
long long kth(long long k) {
  if (zero) k--;
  if (k >= (1ll << cnt)) return -1;
  long long ret = 0;
  for (long long i = S; ~i; i--)
    if (k & (1ll << i)) ret ^= p[i];
  return ret;
}
}  // namespace Basis
using namespace Basis;
namespace Edges {
struct Edge {
  long long to, nxt, val;
} e[(M << 1) + 10];
long long etot, hd[N + 10];
void adde(long long x, long long y, long long z) {
  e[++etot] = {y, hd[x], z}, hd[x] = etot;
}
}  // namespace Edges
using namespace Edges;
void dfs(long long u, long long p, long long Val) {
  vis[u] = 1, val[u] = Val;
  for (long long i = hd[u]; i; i = e[i].nxt) {
    long long v = e[i].to;
    if (v == p) continue;
    if (vis[v])
      insert(val[u] ^ val[v] ^ e[i].val);
    else
      dfs(v, u, val[u] ^ e[i].val);
  }
}
struct OI {
  long long RP, score;
} FJOI2021;
signed main() {
  FJOI2021.RP++, FJOI2021.score++, 392699;
  fr(n), fr(m);
  for (long long i = 1, x, y, z; i <= m; i++)
    fr(x), fr(y), fr(z), adde(x, y, z), adde(y, x, z);
  return dfs(1, 0, 0), printf("%lld\n", minXor(val[n])), 0;
}

```