#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const int Mod = 1000000007;
const int INF = 0x3f3f3f3f;
const long long LL_INF = 0x3f3f3f3f3f3f3f3f;
const double e = exp(1);
const double PI = acos(-1);
const double ERR = 1e-10;
struct linear_basis {
  long long a[65], b[65];
  long long cnt;
  bool flag;
  linear_basis() {
    memset(a, 0, sizeof(a));
    memset(b, 0, sizeof(b));
    cnt = 0;
    flag = false;
  }
  void add(long long x) {
    for (int i = 63; i >= 0; i--) {
      if (x & (1LL << i)) {
        if (a[i]) {
          x ^= a[i];
        } else {
          a[i] = x;
          return;
        }
      }
    }
    flag = true;
  }
  long long query_max() {
    long long res = 0;
    for (int i = 63; i >= 0; i--) {
      res = max(res, res ^ a[i]);
    }
    return res;
  }
  long long query_min() {
    long long res = 0;
    for (int i = 0; i <= 63; i++) {
      if (a[i]) {
        res = a[i];
        break;
      }
    }
    return res;
  }
  void re_build() {
    for (int i = 63; i >= 0; i--) {
      for (int j = i - 1; j >= 0; j--) {
        if (a[i] & (1LL << j)) {
          a[i] ^= a[j];
        }
      }
    }
    for (int i = 0; i <= 63; i++) {
      if (a[i]) {
        b[cnt++] = a[i];
      }
    }
  }
  long long kth_element(long long k) {
    if (flag) k--;
    long long res = 0;
    if (k >= (1LL << cnt)) {
      return -1;
    }
    for (int i = 63; i >= 0; i--) {
      if (k & (1LL << i)) {
        res ^= b[i];
      }
    }
    return res;
  }
} loop;
vector<pair<int, int> > G[maxn];
long long d[maxn];
bool vis[maxn];
void addedge(int u, int v, long long w) { G[u].push_back({v, w}); }
void dfs(int u) {
  vis[u] = true;
  for (auto ed : G[u]) {
    int v = ed.first;
    int w = ed.second;
    if (!vis[v]) {
      d[v] = (d[u] ^ w);
      dfs(v);
    } else {
      loop.add(d[u] ^ d[v] ^ w);
    }
  }
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    long long w;
    scanf("%d%d%lld", &u, &v, &w);
    addedge(u, v, w);
    addedge(v, u, w);
  }
  dfs(1);
  long long ans = d[n];
  for (int i = 63; i >= 0; i--) {
    ans = min(ans, ans ^ loop.a[i]);
  }
  printf("%lld\n", ans);
  return 0;
}

### Prompt

Develop a solution in cpp to the problem described below:

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 int maxn = 1e5 + 5;
const int Mod = 1000000007;
const int INF = 0x3f3f3f3f;
const long long LL_INF = 0x3f3f3f3f3f3f3f3f;
const double e = exp(1);
const double PI = acos(-1);
const double ERR = 1e-10;
struct linear_basis {
  long long a[65], b[65];
  long long cnt;
  bool flag;
  linear_basis() {
    memset(a, 0, sizeof(a));
    memset(b, 0, sizeof(b));
    cnt = 0;
    flag = false;
  }
  void add(long long x) {
    for (int i = 63; i >= 0; i--) {
      if (x & (1LL << i)) {
        if (a[i]) {
          x ^= a[i];
        } else {
          a[i] = x;
          return;
        }
      }
    }
    flag = true;
  }
  long long query_max() {
    long long res = 0;
    for (int i = 63; i >= 0; i--) {
      res = max(res, res ^ a[i]);
    }
    return res;
  }
  long long query_min() {
    long long res = 0;
    for (int i = 0; i <= 63; i++) {
      if (a[i]) {
        res = a[i];
        break;
      }
    }
    return res;
  }
  void re_build() {
    for (int i = 63; i >= 0; i--) {
      for (int j = i - 1; j >= 0; j--) {
        if (a[i] & (1LL << j)) {
          a[i] ^= a[j];
        }
      }
    }
    for (int i = 0; i <= 63; i++) {
      if (a[i]) {
        b[cnt++] = a[i];
      }
    }
  }
  long long kth_element(long long k) {
    if (flag) k--;
    long long res = 0;
    if (k >= (1LL << cnt)) {
      return -1;
    }
    for (int i = 63; i >= 0; i--) {
      if (k & (1LL << i)) {
        res ^= b[i];
      }
    }
    return res;
  }
} loop;
vector<pair<int, int> > G[maxn];
long long d[maxn];
bool vis[maxn];
void addedge(int u, int v, long long w) { G[u].push_back({v, w}); }
void dfs(int u) {
  vis[u] = true;
  for (auto ed : G[u]) {
    int v = ed.first;
    int w = ed.second;
    if (!vis[v]) {
      d[v] = (d[u] ^ w);
      dfs(v);
    } else {
      loop.add(d[u] ^ d[v] ^ w);
    }
  }
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    long long w;
    scanf("%d%d%lld", &u, &v, &w);
    addedge(u, v, w);
    addedge(v, u, w);
  }
  dfs(1);
  long long ans = d[n];
  for (int i = 63; i >= 0; i--) {
    ans = min(ans, ans ^ loop.a[i]);
  }
  printf("%lld\n", ans);
  return 0;
}

```