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;
const int w = 1, x = 1, y = 1, z = -1;
long long int inverse_mod(long long int a, long long int p) {
  vector<long long int> A = {p, 1, 0};
  vector<long long int> B = {a, 0, 1};
  while (B[0] != 1) {
    long long int ratio = A[0] / B[0];
    A[0] -= ratio * B[0];
    A[1] -= ratio * B[1];
    A[2] -= ratio * B[2];
    swap(A, B);
  }
  return (p + (B[2] % p)) % p;
}
void transform(vector<long long int> &pol, long long int mod) {
  int n = pol.size();
  for (int step = 1; step < n; step <<= 1) {
    for (int pos = 0; pos < n; pos += step << 1) {
      for (int i = 0; i < step; ++i) {
        long long int a = pol[pos + i];
        long long int b = pol[pos + i + step];
        pol[pos + i] = (w * a + x * b) % mod;
        pol[pos + i + step] = (y * a + z * b) % mod;
      }
    }
  }
}
void inverse_transform(vector<long long int> &pol, long long int mod) {
  const long long int determinant = (w * z - x * y);
  int n = pol.size();
  for (int step = 1; step < n; step <<= 1) {
    for (int pos = 0; pos < n; pos += step << 1) {
      for (int i = 0; i < step; ++i) {
        long long int a = pol[pos + i];
        long long int b = pol[pos + i + step];
        pol[pos + i] = (z * a - y * b) % mod;
        pol[pos + i + step] = (w * b - x * a) % mod;
      }
    }
  }
  long long int rev = inverse_mod(n, mod);
  if (int(log2(pol.size() + 0.5)) & 1) rev *= -1;
  for (int i = 0; i < n; ++i) {
    pol[i] = (mod + (pol[i] * rev) % mod) % mod;
  }
}
vector<long long int> convolute(vector<long long int> pol1,
                                vector<long long int> pol2, long long int mod) {
  int n = 1;
  while (n < pol1.size() + pol2.size()) n <<= 1;
  pol1.resize(n, 0);
  pol2.resize(n, 0);
  transform(pol1, mod);
  transform(pol2, mod);
  for (int i = 0; i < n; ++i) pol1[i] *= pol2[i];
  inverse_transform(pol1, mod);
  return pol1;
}
vector<vector<long long int> > G, W;
vector<long long int> parent, cost, visited;
vector<vector<long long int> > cycles;
void dfs(int v, int p, int price) {
  parent[v] = p;
  cost[v] = price;
  ++visited[v];
  for (int i = 0; i < G[v].size(); ++i) {
    int u = G[v][i], w = W[v][i];
    if (u == p) continue;
    if (visited[u] == 2) continue;
    if (not visited[u])
      dfs(u, v, w);
    else {
      vector<long long int> weights = {w};
      int it = 0;
      for (int current = v; current != u; current = parent[current]) {
        weights.push_back(cost[current]);
      }
      cycles.push_back(weights);
    }
  }
  ++visited[v];
}
vector<long long int> get_pol(int index) {
  vector<long long int> ans(1e5 + 2, 0);
  for (int i = 0; i < cycles[index].size(); ++i) {
    ++ans[cycles[index][i]];
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long int mod = 1000000007;
  int n, m;
  cin >> n >> m;
  G = W = vector<vector<long long int> >(n);
  long long int total = 0;
  for (int i = 0; i < m; ++i) {
    int x, y, w;
    cin >> x >> y >> w;
    --x;
    --y;
    G[x].push_back(y);
    G[y].push_back(x);
    W[x].push_back(w);
    W[y].push_back(w);
    total ^= w;
  }
  parent = cost = visited = vector<long long int>(n, 0);
  dfs(0, 0, 0);
  int k = 1 << 17;
  vector<long long int> points1(k, 1), points2(k, 1);
  for (int i = 0; i < cycles.size(); ++i) {
    vector<long long int> pol = get_pol(i);
    pol.resize(k, 0);
    transform(pol, mod);
    for (int i = 0; i < k; ++i) points1[i] = points1[i] * pol[i] % mod;
    pol = get_pol(i);
    pol.resize(k, 0);
    transform(pol, mod + 2);
    for (int i = 0; i < k; ++i) points2[i] = points2[i] * pol[i] % (mod + 2);
  }
  inverse_transform(points1, mod);
  inverse_transform(points2, mod + 2);
  long long int smallest = 1e18, times = 0;
  for (int i = 0; i < points1.size(); ++i) {
    if (not points1[i] and not points2[i]) continue;
    if ((i ^ total) < smallest) {
      smallest = i ^ total;
      times = (mod + points1[i] % mod) % mod;
    }
  }
  cout << smallest << ' ' << times << '\n';
}