#include <bits/stdc++.h>   const int maxn = 1e5 + 51;   const int mod1 = 1e9 + 7;   const int mod2 = 1e9 + 9;   std::vector<std::pair<int, int>> g[maxn];   int dfn[maxn], idx = 0;   int f[maxn], fw[maxn];   int xr;   std::vector<std::vector<int>> V;   void dfs(int u, int fa) {     dfn[u] = ++idx;     for (auto x : g[u]) {       int v = x.first, w = x.second;       if (v == fa) continue;       if (!dfn[v]) {         f[v] = u, fw[v] = w;         dfs(v, u);       } else if (dfn[v] > dfn[u]) {         std::vector<int> vec;         int cur = w;         for (int now = v; now ^ u; now = f[now]) cur ^= fw[now];         vec.push_back(cur ^ w);         for (int now = v; now ^ u; now = f[now]) vec.push_back(cur ^ fw[now]);         xr ^= cur;         V.push_back(vec);       }     }   }   int add(int x, int y, const int& mod) {     x += y;     return (x >= mod) ? x - mod : x;   }   int dec(int x, int y, const int& mod) {     x -= y;     return (x < 0) ? x + mod : x;   }   int n, m;   int main() {     std::ios::sync_with_stdio(false);     std::cin.tie(nullptr);     std::cout.tie(nullptr);     std::cin >> n >> m;     for (int i = 1; i <= m; i++) {       int u, v, w;       std::cin >> u >> v >> w;       g[u].push_back({v, w});       g[v].push_back({u, w});       xr ^= w;     }     dfs(1, 0);     static int a[1 << 17 | 3], b[1 << 17 | 3];     auto fwt = [&](int* f, int lim, const int& inv, const int& mod) {       for (int len = 1; len < lim; len <<= 1) {         for (int i = 0; i < lim; i += len << 1) {           for (int j = 0; j < len; j++) {             int x = f[i + j], y = f[i + j + len];             f[i + j] = add(x, y, mod);             f[i + j + len] = dec(x, y, mod);             if (inv > 1)               f[i + j] = 1ll * f[i + j] * inv % mod,                     f[i + j + len] = 1ll * f[i + j + len] * inv % mod;           }         }       }     };     a[xr] = 1, b[xr] = 1;     fwt(a, 1 << 17, 1, mod1);     fwt(b, 1 << 17, 1, mod2);     static int c[1 << 17 | 3], d[1 << 17 | 3];     for (auto v : V) {       memset(c, 0, sizeof(c));       memset(d, 0, sizeof(d));       for (auto x : v) c[x]++, d[x]++;       fwt(c, 1 << 17, 1, mod1);       fwt(d, 1 << 17, 1, mod2);       for (int i = 0; i < (1 << 17); i++) {         a[i] = 1ll * a[i] * c[i] % mod1;         b[i] = 1ll * b[i] * d[i] % mod2;       }     }     fwt(a, 1 << 17, (mod1 + 1) >> 1, mod1);     fwt(b, 1 << 17, (mod2 + 1) >> 1, mod2);     for (int i = 0; i < (1 << 17); i++)       if (a[i] || b[i]) {         std::cout << i <<     << a[i] <<   n ;         return 0;       }     return 0;   }   