#include <bits/stdc++.h>
using namespace std;
const long long _ = 1 << 21;
struct I {
  char fin[_], *p1 = fin, *p2 = fin;
  inline char gc() {
    return (p1 == p2) && (p2 = (p1 = fin) + fread(fin, 1, _, stdin), p1 == p2)
               ? EOF
               : *p1++;
  }
  inline I& operator>>(long long& x) {
    bool sign = 1;
    char c = 0;
    while (c < 48) ((c = gc()) == 45) && (sign = 0);
    x = (c & 15);
    while ((c = gc()) > 47) x = (x << 1) + (x << 3) + (c & 15);
    x = sign ? x : -x;
    return *this;
  }
  inline I& operator>>(double& x) {
    bool sign = 1;
    char c = 0;
    while (c < 48) ((c = gc()) == 45) && (sign = 0);
    x = (c - 48);
    while ((c = gc()) > 47) x = x * 10 + (c - 48);
    if (c == '.') {
      double d = 1.0;
      while ((c = gc()) > 47) d = d * 0.1, x = x + (d * (c - 48));
    }
    x = sign ? x : -x;
    return *this;
  }
  inline I& operator>>(char& x) {
    do x = gc();
    while (isspace(x));
    return *this;
  }
  inline I& operator>>(string& s) {
    s = "";
    char c = gc();
    while (isspace(c)) c = gc();
    while (!isspace(c) && c != EOF) s += c, c = gc();
    return *this;
  }
} in;
struct O {
  char st[100], fout[_];
  signed stk = 0, top = 0;
  inline void flush() { fwrite(fout, 1, top, stdout), fflush(stdout), top = 0; }
  inline O& operator<<(long long x) {
    if (top > (1 << 20)) flush();
    if (x < 0) fout[top++] = 45, x = -x;
    do st[++stk] = x % 10 ^ 48, x /= 10;
    while (x);
    while (stk) fout[top++] = st[stk--];
    return *this;
  }
  inline O& operator<<(char x) {
    fout[top++] = x;
    return *this;
  }
  inline O& operator<<(string s) {
    if (top > (1 << 20)) flush();
    for (char x : s) fout[top++] = x;
    return *this;
  }
} out;
template <class T>
inline void cmax(T& x, const T& y) {
  (x < y) && (x = y);
}
template <class T>
inline void cmin(T& x, const T& y) {
  (x > y) && (x = y);
}
long long n, m;
const long long N = 2e5 + 52;
const long long M = 2e5 + 52;
long long cnt = 0, head[N];
struct Edge {
  long long v, nxt, w;
} e[M << 1];
long long d[N], p[65];
bool vis[N];
void add(long long u, long long v, long long w) {
  e[++cnt] = {v, head[u], w}, head[u] = cnt;
  e[++cnt] = {u, head[v], w}, head[v] = cnt;
}
void insert(long long val) {
  for (long long i = 63; ~i; --i)
    if (val & (1ll << i)) {
      if (!p[i]) p[i] = val;
      val ^= p[i];
    }
}
void dfs(long long u, long long cur) {
  d[u] = cur, vis[u] = 1;
  for (long long i = head[u]; i; i = e[i].nxt) {
    long long v = e[i].v;
    if (vis[v])
      insert(cur ^ e[i].w ^ d[v]);
    else
      dfs(v, cur ^ e[i].w);
  }
}
long long query(long long val) {
  long long res = val;
  for (long long i = 63; ~i; --i) cmin(res, res ^ p[i]);
  return res;
}
signed main() {
  in >> n >> m;
  long long u, v, w;
  while (m--) {
    in >> u >> v >> w, add(u, v, w);
  }
  dfs(1, 0);
  out << query(d[n]) << '\n';
  return out.flush(), 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;
const long long _ = 1 << 21;
struct I {
  char fin[_], *p1 = fin, *p2 = fin;
  inline char gc() {
    return (p1 == p2) && (p2 = (p1 = fin) + fread(fin, 1, _, stdin), p1 == p2)
               ? EOF
               : *p1++;
  }
  inline I& operator>>(long long& x) {
    bool sign = 1;
    char c = 0;
    while (c < 48) ((c = gc()) == 45) && (sign = 0);
    x = (c & 15);
    while ((c = gc()) > 47) x = (x << 1) + (x << 3) + (c & 15);
    x = sign ? x : -x;
    return *this;
  }
  inline I& operator>>(double& x) {
    bool sign = 1;
    char c = 0;
    while (c < 48) ((c = gc()) == 45) && (sign = 0);
    x = (c - 48);
    while ((c = gc()) > 47) x = x * 10 + (c - 48);
    if (c == '.') {
      double d = 1.0;
      while ((c = gc()) > 47) d = d * 0.1, x = x + (d * (c - 48));
    }
    x = sign ? x : -x;
    return *this;
  }
  inline I& operator>>(char& x) {
    do x = gc();
    while (isspace(x));
    return *this;
  }
  inline I& operator>>(string& s) {
    s = "";
    char c = gc();
    while (isspace(c)) c = gc();
    while (!isspace(c) && c != EOF) s += c, c = gc();
    return *this;
  }
} in;
struct O {
  char st[100], fout[_];
  signed stk = 0, top = 0;
  inline void flush() { fwrite(fout, 1, top, stdout), fflush(stdout), top = 0; }
  inline O& operator<<(long long x) {
    if (top > (1 << 20)) flush();
    if (x < 0) fout[top++] = 45, x = -x;
    do st[++stk] = x % 10 ^ 48, x /= 10;
    while (x);
    while (stk) fout[top++] = st[stk--];
    return *this;
  }
  inline O& operator<<(char x) {
    fout[top++] = x;
    return *this;
  }
  inline O& operator<<(string s) {
    if (top > (1 << 20)) flush();
    for (char x : s) fout[top++] = x;
    return *this;
  }
} out;
template <class T>
inline void cmax(T& x, const T& y) {
  (x < y) && (x = y);
}
template <class T>
inline void cmin(T& x, const T& y) {
  (x > y) && (x = y);
}
long long n, m;
const long long N = 2e5 + 52;
const long long M = 2e5 + 52;
long long cnt = 0, head[N];
struct Edge {
  long long v, nxt, w;
} e[M << 1];
long long d[N], p[65];
bool vis[N];
void add(long long u, long long v, long long w) {
  e[++cnt] = {v, head[u], w}, head[u] = cnt;
  e[++cnt] = {u, head[v], w}, head[v] = cnt;
}
void insert(long long val) {
  for (long long i = 63; ~i; --i)
    if (val & (1ll << i)) {
      if (!p[i]) p[i] = val;
      val ^= p[i];
    }
}
void dfs(long long u, long long cur) {
  d[u] = cur, vis[u] = 1;
  for (long long i = head[u]; i; i = e[i].nxt) {
    long long v = e[i].v;
    if (vis[v])
      insert(cur ^ e[i].w ^ d[v]);
    else
      dfs(v, cur ^ e[i].w);
  }
}
long long query(long long val) {
  long long res = val;
  for (long long i = 63; ~i; --i) cmin(res, res ^ p[i]);
  return res;
}
signed main() {
  in >> n >> m;
  long long u, v, w;
  while (m--) {
    in >> u >> v >> w, add(u, v, w);
  }
  dfs(1, 0);
  out << query(d[n]) << '\n';
  return out.flush(), 0;
}

```