#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
const bool CASES = false;
int readInt() {
  int x;
  scanf("%d", &x);
  return x;
}
double readDouble() {
  double x;
  scanf("%lf", &x);
  return x;
}
long long readLL() {
  long long x;
  scanf("%lld", &x);
  return x;
}
class Gauss {
 private:
  vector<long long> base;

 public:
  void add(long long nr) { base.push_back(nr); }
  void computeBase() {
    int cnt = 0;
    for (int bit = 60; bit >= 0; --bit) {
      bool found = false;
      for (int i = cnt; i < base.size(); ++i)
        if (base[i] & (1ll << bit)) {
          found = true;
          swap(base[i], base[cnt]);
        }
      if (!found) continue;
      for (int i = cnt + 1; i < base.size(); ++i)
        if (base[i] & (1ll << bit)) base[i] ^= base[cnt];
      ++cnt;
    }
    base.resize(cnt);
  }
  long long query(long long nr) {
    for (auto it : base)
      if ((nr ^ it) < nr) nr ^= it;
    return nr;
  }
};
int n, m, q;
vector<pair<int, long long>> adj[MAXN];
int a[MAXN], b[MAXN];
long long c[MAXN];
bool spanning[MAXN];
int queries_a[MAXN * 10], queries_b[MAXN * 10];
void input_case() {
  n = readInt();
  m = readInt();
  q = 100000;
  for (int i = 1; i <= m; i++) {
    a[i] = readInt();
    b[i] = readInt();
    c[i] = readLL();
  }
  queries_a[1] = 1;
  queries_b[1] = n;
  for (int i = 2; i <= q; i++) {
    queries_a[i] = n / 2 - 3;
    queries_b[i] = min(n, n / 2 + 5);
  }
}
int par[MAXN];
long long dist[MAXN];
int get(int x) {
  if (par[x] == x) return x;
  return par[x] = get(par[x]);
}
bool unite(int x, int y) {
  x = get(x);
  y = get(y);
  if (x == y) return false;
  if (rand() % 2) swap(x, y);
  par[x] = y;
  return true;
}
void dfs(int src, int par, long long d) {
  dist[src] = d;
  for (auto &xt : adj[src]) {
    if (xt.first != par) dfs(xt.first, src, d ^ xt.second);
  }
}
void solve_case() {
  srand(time(NULL));
  for (int i = 1; i <= n; i++) par[i] = i;
  for (int i = 1; i <= m; i++) {
    if (unite(a[i], b[i])) {
      adj[a[i]].push_back({b[i], c[i]});
      adj[b[i]].push_back({a[i], c[i]});
      spanning[i] = true;
    }
  }
  Gauss g;
  int root = 1;
  dfs(root, -1, 0);
  for (int i = 1; i <= m; i++) {
    if (!spanning[i]) {
      long long val = dist[a[i]] ^ c[i] ^ dist[b[i]];
      g.add(val);
    }
  }
  g.computeBase();
  for (int i = 1; i <= q; i++) {
    long long any = dist[queries_a[i]] ^ dist[queries_b[i]];
    if (i == 1) printf("%lld\n", g.query(any));
  }
}
void solve() {
  int T = CASES ? readInt() : 1;
  while (T--) {
    input_case();
    solve_case();
  }
}
int main() {
  solve();
  return 0;
}

### Prompt

In Cpp, your task is to solve 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 int MAXN = 100010;
const bool CASES = false;
int readInt() {
  int x;
  scanf("%d", &x);
  return x;
}
double readDouble() {
  double x;
  scanf("%lf", &x);
  return x;
}
long long readLL() {
  long long x;
  scanf("%lld", &x);
  return x;
}
class Gauss {
 private:
  vector<long long> base;

 public:
  void add(long long nr) { base.push_back(nr); }
  void computeBase() {
    int cnt = 0;
    for (int bit = 60; bit >= 0; --bit) {
      bool found = false;
      for (int i = cnt; i < base.size(); ++i)
        if (base[i] & (1ll << bit)) {
          found = true;
          swap(base[i], base[cnt]);
        }
      if (!found) continue;
      for (int i = cnt + 1; i < base.size(); ++i)
        if (base[i] & (1ll << bit)) base[i] ^= base[cnt];
      ++cnt;
    }
    base.resize(cnt);
  }
  long long query(long long nr) {
    for (auto it : base)
      if ((nr ^ it) < nr) nr ^= it;
    return nr;
  }
};
int n, m, q;
vector<pair<int, long long>> adj[MAXN];
int a[MAXN], b[MAXN];
long long c[MAXN];
bool spanning[MAXN];
int queries_a[MAXN * 10], queries_b[MAXN * 10];
void input_case() {
  n = readInt();
  m = readInt();
  q = 100000;
  for (int i = 1; i <= m; i++) {
    a[i] = readInt();
    b[i] = readInt();
    c[i] = readLL();
  }
  queries_a[1] = 1;
  queries_b[1] = n;
  for (int i = 2; i <= q; i++) {
    queries_a[i] = n / 2 - 3;
    queries_b[i] = min(n, n / 2 + 5);
  }
}
int par[MAXN];
long long dist[MAXN];
int get(int x) {
  if (par[x] == x) return x;
  return par[x] = get(par[x]);
}
bool unite(int x, int y) {
  x = get(x);
  y = get(y);
  if (x == y) return false;
  if (rand() % 2) swap(x, y);
  par[x] = y;
  return true;
}
void dfs(int src, int par, long long d) {
  dist[src] = d;
  for (auto &xt : adj[src]) {
    if (xt.first != par) dfs(xt.first, src, d ^ xt.second);
  }
}
void solve_case() {
  srand(time(NULL));
  for (int i = 1; i <= n; i++) par[i] = i;
  for (int i = 1; i <= m; i++) {
    if (unite(a[i], b[i])) {
      adj[a[i]].push_back({b[i], c[i]});
      adj[b[i]].push_back({a[i], c[i]});
      spanning[i] = true;
    }
  }
  Gauss g;
  int root = 1;
  dfs(root, -1, 0);
  for (int i = 1; i <= m; i++) {
    if (!spanning[i]) {
      long long val = dist[a[i]] ^ c[i] ^ dist[b[i]];
      g.add(val);
    }
  }
  g.computeBase();
  for (int i = 1; i <= q; i++) {
    long long any = dist[queries_a[i]] ^ dist[queries_b[i]];
    if (i == 1) printf("%lld\n", g.query(any));
  }
}
void solve() {
  int T = CASES ? readInt() : 1;
  while (T--) {
    input_case();
    solve_case();
  }
}
int main() {
  solve();
  return 0;
}

```