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;
inline int nxt() {
  int x;
  scanf("%d", &x);
  return x;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int L = 17;
const int N = 1 << L;
long long a[N];
long long aa[N];
long long b[N];
long long bb[N];
void wh(long long* b, long long* e) {
  if (e == b + 1) {
    return;
  }
  long long* m = b + (e - b) / 2;
  wh(b, m);
  wh(m, e);
  while (m != e) {
    *b += *m;
    *m = *b - 2 * (*m);
    ++b, ++m;
  }
}
vector<pair<int, int>> g[N];
vector<int> huili;
vector<char> used;
vector<pair<int, int>> order;
void dfs(int v, int p) {
  used[v] = 1;
  for (const auto& [to, id] : g[v]) {
    if (id == p) {
      continue;
    }
    if (used[to] == 1) {
      continue;
    } else if (used[to]) {
      huili.push_back(id);
    } else {
      dfs(to, id);
    }
  }
  if (p > -1) {
    order.push_back({v, p});
  }
  used[v] = 2;
}
int main() {
  int n = nxt(), m = nxt();
  vector<int> w(m);
  for (int i = 0; i < m; ++i) {
    int u = nxt() - 1, v = nxt() - 1;
    w[i] = nxt();
    g[u].push_back({v, i});
    g[v].push_back({u, i});
  }
  used.assign(n, 0);
  dfs(0, -1);
  vector<long long> shit(m);
  for (int x : huili) {
    shit[x] = rng() % 1000000000;
    shit[x] <<= 31;
    shit[x] |= (long long)rng() % 1000000000;
  }
  for (const auto& [v, id] : order) {
    for (const auto& [to, idx] : g[v]) {
      assert(to > -1);
      if (id == idx) {
        continue;
      }
      shit[id] ^= shit[idx];
    }
  }
  vector<char> bridges(m);
  int off = 0;
  for (int i = 0; i < m; ++i) {
    bridges[i] = (shit[i] == 0);
    off ^= w[i];
  }
  used.assign(n, 0);
  a[off] = 1;
  aa[off] = 1;
  const int mod = 1000000007;
  int d2 = 1;
  for (int i = 0; i < L; ++i) {
    if (d2 % 2) {
      d2 += mod;
    }
    d2 /= 2;
  }
  for (int i = 0; i < n; ++i) {
    if (used[i]) {
      continue;
    }
    vector<int> st = {i};
    used[i] = 1;
    int cn = 0;
    while (!st.empty()) {
      ++cn;
      int v = st.back();
      st.pop_back();
      for (const auto& [to, id] : g[v]) {
        if (bridges[id]) {
          continue;
        }
        b[w[id]] += 1;
        if (!used[to]) {
          used[to] = 1;
          st.push_back(to);
        }
      }
    }
    if (cn == 1) {
      continue;
    }
    for (int i = 0; i < N; ++i) {
      b[i] /= 2;
      bb[i] = b[i];
    }
    wh(a, a + N);
    wh(b, b + N);
    wh(aa, aa + N);
    wh(bb, bb + N);
    for (int i = 0; i < N; ++i) {
      a[i] %= mod;
      b[i] %= mod;
      if (a[i] < 0) {
        a[i] += mod;
      }
      if (b[i] < 0) {
        b[i] += mod;
      }
      a[i] *= b[i];
      a[i] %= mod;
      aa[i] *= bb[i];
    }
    wh(a, a + N);
    wh(aa, aa + N);
    for (int i = 0; i < N; ++i) {
      a[i] = a[i] % mod * d2 % mod;
      if (a[i] < 0) {
        a[i] += mod;
      }
      aa[i] = min(aa[i], 1ll);
    }
    memset(b, 0, sizeof(b));
  }
  int idx = 0;
  while (a[idx] == 0 && aa[idx] == 0) {
    ++idx;
  }
  cout << idx << " " << a[idx] << "\n";
  return 0;
}