#include <bits/stdc++.h>
using namespace std;
const int mod1 = 1e9 + 7, mod2 = (117 << 23) + 1;
int n, m, state[100000], edge_xor, cyc_count, ans = -1;
vector<int> cyc_xors[44];
vector<pair<int, int>> g[100000], dfs_stack;
int mul(int a, int b, int mod) { return ((long long)a * b) % mod; }
int exp(int a, int b, int mod) {
  int ret = 1;
  while (b) {
    if (b & 1) {
      ret = mul(ret, a, mod);
    }
    a = mul(a, a, mod), b >>= 1;
  }
  return ret;
}
void dfs(int x, int p = 0) {
  state[x] = 1;
  for (pair<int, int> e : g[x]) {
    if (state[e.first] == 0) {
      dfs_stack.push_back({x, e.second});
      dfs(e.first, x);
      dfs_stack.pop_back();
    } else if (e.first != p && state[e.first] == 1) {
      cyc_xors[++cyc_count].resize((1 << 17));
      ++cyc_xors[cyc_count][e.second];
      for (int i = dfs_stack.size() - 1;; i--) {
        ++cyc_xors[cyc_count][dfs_stack[i].second];
        if (dfs_stack[i].first == e.first) {
          break;
        }
      }
    }
  }
  state[x] = 2;
}
void fwht(vector<int>& a, bool inv, int mod) {
  int sz = a.size();
  for (int i = 1, j = 0; i < sz; i++) {
    int bit = sz >> 1;
    for (; j & bit; bit >>= 1) {
      j ^= bit;
    }
    j ^= bit;
    if (i < j) {
      swap(a[i], a[j]);
    }
  }
  for (int len = 1; len < sz; len <<= 1) {
    for (int i = 0; i < sz; i += 2 * len) {
      for (int j = i; j < i + len; j++) {
        int x = a[j], y = a[j + len];
        a[j] = (x + y) % mod;
        a[j + len] = (x - y + mod) % mod;
      }
    }
  }
  if (inv) {
    int inv_n = exp(sz, mod - 2, mod);
    for (int i = 0; i < sz; i++) {
      a[i] = mul(a[i], inv_n, mod);
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0, u, v, w; i < m; i++) {
    cin >> u >> v >> w;
    g[u - 1].push_back({v - 1, w});
    g[v - 1].push_back({u - 1, w});
    edge_xor ^= w;
  }
  cyc_xors[0].resize((1 << 17)), cyc_xors[43].resize((1 << 17));
  cyc_xors[0][0] = 1, fwht(cyc_xors[0], false, mod1);
  cyc_xors[43][0] = 1, fwht(cyc_xors[43], false, mod2);
  dfs(0);
  for (int i = 1; i <= cyc_count; i++) {
    fwht(cyc_xors[i], false, mod1);
    for (int j = 0; j < (1 << 17); j++) {
      cyc_xors[0][j] = mul(cyc_xors[0][j], cyc_xors[i][j], mod1);
    }
    fwht(cyc_xors[i], true, mod1);
    fwht(cyc_xors[i], false, mod2);
    for (int j = 0; j < (1 << 17); j++) {
      cyc_xors[43][j] = mul(cyc_xors[43][j], cyc_xors[i][j], mod2);
    }
  }
  fwht(cyc_xors[0], true, mod1);
  fwht(cyc_xors[43], true, mod2);
  for (int i = 0; i < (1 << 17); i++) {
    if ((cyc_xors[0][i] > 0 || cyc_xors[43][i] > 0) &&
        (ans == -1 || ((edge_xor ^ i) < (edge_xor ^ ans)))) {
      ans = i;
    }
  }
  cout << (edge_xor ^ ans) << " " << cyc_xors[0][ans] << endl;
}

### Prompt

Construct a Cpp code solution to the problem outlined:

In the galaxy far far away is the ancient interplanetary republic of Bubbleland, consisting of N planets. Between them, there are M bidirectional wormholes, each connecting a pair of planets. Bubbleland is a very centralized republic, having a capital planet Whiteplanet, from which any another planet can be reached using these wormholes. It is also guaranteed that no wormhole connects planet to itself and that no two different wormholes connect same pair of planets. 

We call a path that begins at one planet, visits other planets and each of them at most once and returns to starting point a tour. Interplanetary Safety Regulations guarantee that each planet belongs to at most one tour and that there are at most 42 tours.

After many eons of usage, wormholes need to be repaired and each wormhole has the cost W_{i} which needs to be payed for reparation. Unfortunately, the Senate of Bubbleland is short on budget. Therefore, they have decided only to fix as many wormholes as they need in order to have all planets reachable from capital and to pay as little money as they have to for this repair. However the way in which the Senate calculates the cost is different. Cost of the set of reparations is binary xor of costs of each individual reparation, that is if reparations to be made have costs A_{1},A_{2},...,A_{k}, the cost of entire set is A_{1} ⊕ A_{2} ⊕ ... ⊕ A_{k}.

Now the Senate would like to know how much money do they have to pay and also the number of different ways to achieve that cost modulo 1000000007.

Input

First line of input contains two numbers N (1 ≤ N ≤ 100.000), the number of planets and M (1 ≤ M ≤ 100.041), the number of wormholes. Following M lines contain three numbers U, V (1 ≤ U ≠ V ≤ N) and W (1 ≤ W ≤ 100.000), meaning that there exists a wormhole connecting planets U and V, with repair cost of W.

Output

Output two numbers, the smallest possible cost of entire reparation and the number of different valid reparations with that cost modulo 1000000007.

Example

Input


6 6
4 1 5
5 2 1
6 3 2
1 2 6
1 3 3
2 3 4


Output


1 1

Note

We can repair wormholes 1,2,3,5 and 6, paying 5 ⊕ 1⊕ 2 ⊕ 3 ⊕ 4=1, one can check that this is the cheapest repair in which all of the planets are connected and the only valid repair with that cost.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int mod1 = 1e9 + 7, mod2 = (117 << 23) + 1;
int n, m, state[100000], edge_xor, cyc_count, ans = -1;
vector<int> cyc_xors[44];
vector<pair<int, int>> g[100000], dfs_stack;
int mul(int a, int b, int mod) { return ((long long)a * b) % mod; }
int exp(int a, int b, int mod) {
  int ret = 1;
  while (b) {
    if (b & 1) {
      ret = mul(ret, a, mod);
    }
    a = mul(a, a, mod), b >>= 1;
  }
  return ret;
}
void dfs(int x, int p = 0) {
  state[x] = 1;
  for (pair<int, int> e : g[x]) {
    if (state[e.first] == 0) {
      dfs_stack.push_back({x, e.second});
      dfs(e.first, x);
      dfs_stack.pop_back();
    } else if (e.first != p && state[e.first] == 1) {
      cyc_xors[++cyc_count].resize((1 << 17));
      ++cyc_xors[cyc_count][e.second];
      for (int i = dfs_stack.size() - 1;; i--) {
        ++cyc_xors[cyc_count][dfs_stack[i].second];
        if (dfs_stack[i].first == e.first) {
          break;
        }
      }
    }
  }
  state[x] = 2;
}
void fwht(vector<int>& a, bool inv, int mod) {
  int sz = a.size();
  for (int i = 1, j = 0; i < sz; i++) {
    int bit = sz >> 1;
    for (; j & bit; bit >>= 1) {
      j ^= bit;
    }
    j ^= bit;
    if (i < j) {
      swap(a[i], a[j]);
    }
  }
  for (int len = 1; len < sz; len <<= 1) {
    for (int i = 0; i < sz; i += 2 * len) {
      for (int j = i; j < i + len; j++) {
        int x = a[j], y = a[j + len];
        a[j] = (x + y) % mod;
        a[j + len] = (x - y + mod) % mod;
      }
    }
  }
  if (inv) {
    int inv_n = exp(sz, mod - 2, mod);
    for (int i = 0; i < sz; i++) {
      a[i] = mul(a[i], inv_n, mod);
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0, u, v, w; i < m; i++) {
    cin >> u >> v >> w;
    g[u - 1].push_back({v - 1, w});
    g[v - 1].push_back({u - 1, w});
    edge_xor ^= w;
  }
  cyc_xors[0].resize((1 << 17)), cyc_xors[43].resize((1 << 17));
  cyc_xors[0][0] = 1, fwht(cyc_xors[0], false, mod1);
  cyc_xors[43][0] = 1, fwht(cyc_xors[43], false, mod2);
  dfs(0);
  for (int i = 1; i <= cyc_count; i++) {
    fwht(cyc_xors[i], false, mod1);
    for (int j = 0; j < (1 << 17); j++) {
      cyc_xors[0][j] = mul(cyc_xors[0][j], cyc_xors[i][j], mod1);
    }
    fwht(cyc_xors[i], true, mod1);
    fwht(cyc_xors[i], false, mod2);
    for (int j = 0; j < (1 << 17); j++) {
      cyc_xors[43][j] = mul(cyc_xors[43][j], cyc_xors[i][j], mod2);
    }
  }
  fwht(cyc_xors[0], true, mod1);
  fwht(cyc_xors[43], true, mod2);
  for (int i = 0; i < (1 << 17); i++) {
    if ((cyc_xors[0][i] > 0 || cyc_xors[43][i] > 0) &&
        (ans == -1 || ((edge_xor ^ i) < (edge_xor ^ ans)))) {
      ans = i;
    }
  }
  cout << (edge_xor ^ ans) << " " << cyc_xors[0][ans] << endl;
}

```