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 max_lev = 17;
const int max_n = 1 << max_lev;
const int mod = 1000000007;
const int mod1 = 1000000009;
int n, dp[max_n], sz[max_n], used[max_n], parent[max_n], pw[max_n];
int ans[max_n], cnt[max_n], h[max_n];
int ans1[max_n], cnt1[max_n];
vector<int> g[max_n], w[max_n];
int mul(int x, int y, int mod) { return 1LL * x * y % mod; }
int power(int x, int y, int mod) {
  if (y == 0) {
    return 1;
  }
  if (y % 2 == 0) {
    return power(mul(x, x, mod), y / 2, mod);
  }
  return mul(x, power(x, y - 1, mod), mod);
}
int rn = power(max_n, mod - 2, mod), all;
int rn1 = power(max_n, mod1 - 2, mod1);
void proc(int lev, int *a, int mod) {
  if (lev == 0) {
    return;
  }
  const int n = 1 << (lev - 1);
  for (int i = 0; i < n; ++i) {
    int x = (a[i] + a[i + n]) % mod;
    int y = (a[i] + mod - a[i + n]) % mod;
    a[i] = x;
    a[i + n] = y;
  }
  proc(lev - 1, a, mod);
  proc(lev - 1, a + n, mod);
}
void dfs(int v, int p) {
  used[v] = 1;
  parent[v] = p;
  for (int i = 0; i < g[v].size(); ++i) {
    const int to = g[v][i];
    if (to == p) {
      continue;
    }
    if (used[to]) {
      if (h[to] > h[v]) {
        continue;
      }
      memset(cnt, 0, sizeof(cnt));
      memset(cnt1, 0, sizeof(cnt1));
      cnt[w[v][i]] = 1;
      cnt1[w[v][i]] = 1;
      int cur = v;
      while (true) {
        if (cur == to) {
          break;
        }
        ++cnt[pw[cur]];
        ++cnt1[pw[cur]];
        cur = parent[cur];
      }
      proc(max_lev, cnt, mod);
      proc(max_lev, cnt1, mod1);
      for (int i = 0; i < max_n; ++i) {
        ans[i] = mul(ans[i], cnt[i], mod);
        ans1[i] = mul(ans1[i], cnt1[i], mod1);
      }
    } else {
      h[to] = h[v] + 1;
      pw[to] = w[v][i];
      dfs(to, v);
    }
  }
}
int main() {
  int m;
  scanf("%d%d", &n, &m);
  while (m--) {
    int u, v, x;
    scanf("%d%d%d", &u, &v, &x);
    --u;
    --v;
    g[u].push_back(v);
    w[u].push_back(x);
    g[v].push_back(u);
    w[v].push_back(x);
    all ^= x;
  }
  ans[all] = 1;
  ans1[all] = 1;
  proc(max_lev, ans, mod);
  proc(max_lev, ans1, mod1);
  dfs(0, -1);
  proc(max_lev, ans, mod);
  proc(max_lev, ans1, mod1);
  for (int i = 0; i < max_n; ++i) {
    ans[i] = mul(ans[i], rn, mod);
    ans1[i] = mul(ans1[i], rn1, mod1);
  }
  for (int i = 0; i < max_n; ++i) {
    if (ans[i] || ans1[i]) {
      printf("%d %d", i, ans[i]);
      return 0;
    }
  }
  return 0;
}