Problem: 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.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const int N = 1e5;
const int K = 50;
const int H = 17;
vector<pair<int, int>> conns[N];
vector<int> cycles[K];
int visited[N];
ll modInv(ll a, ll b = MOD - 2) {
  if (b & 1) return a * modInv(a, b ^ 1) % MOD;
  if (b == 0) return 1;
  return modInv(a * a % MOD, b >> 1);
}
int TI = modInv(1 << H);
void xorTF(vector<int>& v) {
  for (int b = 1; b < v.size(); b *= 2) {
    for (int i = 0; i < v.size(); ++i) {
      if (i & b) continue;
      int ri = v[i ^ b];
      v[i ^ b] = v[i] - ri;
      v[i] = v[i] + ri;
      if (v[i ^ b] < 0) v[i ^ b] += MOD;
      if (v[i] >= MOD) v[i] -= MOD;
    }
  }
}
vector<int> xorConv(vector<int> a, vector<int> b) {
  xorTF(a);
  xorTF(b);
  for (int i = 0; i < a.size(); ++i) a[i] = (ll)a[i] * b[i] % MOD;
  xorTF(a);
  for (int& v : a) v = (ll)v * TI % MOD;
  return a;
}
pair<int, int> dfs(int i, int p, int& cc) {
  visited[i] = visited[p] + 1;
  pair<int, int> res = {-1, -1};
  for (auto pr : conns[i]) {
    int t = pr.first;
    if (t == p) continue;
    if (visited[t]) {
      if (visited[t] < visited[i]) {
        res = {t, cc};
        cycles[cc].resize(1 << H, 0);
        ++cycles[cc][pr.second];
        ++cc;
      }
    } else {
      auto sub = dfs(t, i, cc);
      if (sub.first != -1) {
        res = sub;
        ++cycles[res.second][pr.second];
      }
    }
  }
  if (res.first == i) res = {-1, -1};
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  int xr = 0;
  for (int i = 0; i < m; ++i) {
    int a, b, w;
    cin >> a >> b >> w;
    --a;
    --b;
    conns[a].push_back({b, w});
    conns[b].push_back({a, w});
    xr ^= w;
  }
  int cc = 0;
  dfs(0, 0, cc);
  vector<int> res(1 << H, 0);
  res[0] = 1;
  vector<int> can = res;
  for (int i = 0; i < cc; ++i) {
    res = xorConv(res, cycles[i]);
    can = xorConv(can, cycles[i]);
    for (int& v : can) v = min(v, 1);
  }
  for (int j = 0; j < (1 << H); ++j) {
    if (can[j ^ xr]) {
      cout << j << ' ' << res[j ^ xr] << '\n';
      break;
    }
  }
}