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;
template <typename T1, typename T2>
inline void chkmin(T1 &x, T2 y) {
  x = (x > y ? y : x);
}
template <typename T1, typename T2>
inline void chkmax(T1 &x, T2 y) {
  x = (x < y ? y : x);
}
using ll = long long;
const string FILENAME = "input";
const int mx = 1e5 + 228;
int n, m, xr, up[mx], p[mx], used[mx], tin[mx], timer;
vector<vector<pair<int, int> > > g;
vector<vector<int> > cycles;
void dfs(int v, int pv) {
  tin[v] = timer++;
  used[v] = 1;
  for (auto pp : g[v]) {
    int v1 = pp.first, w = pp.second;
    if (v1 == pv) {
      continue;
    }
    if (used[v1] == 0) {
      p[v1] = v;
      up[v1] = pp.second;
      dfs(v1, v);
    } else {
      if (tin[v1] < tin[v]) {
        vector<int> cur_cycle;
        cur_cycle.push_back(pp.second);
        for (int u = v; u != v1; u = p[u]) {
          cur_cycle.push_back(up[u]);
        }
        cycles.push_back(cur_cycle);
      }
    }
  }
}
const int B = 17;
const int MX = (1 << B);
ll MOD = 1e9 + 7;
ll power(ll a, ll deg) {
  ll res = 1;
  while (deg) {
    if ((deg & 1LL) == 0) {
      a = (a * a) % MOD;
      deg >>= 1;
    } else {
      res = (res * a) % MOD;
      deg -= 1;
    }
  }
  return res;
}
ll inverse(ll x) { return power(x, MOD - 2); }
ll _MX = inverse(MX);
void conv(ll *a, int rev) {
  for (int b = 0; b < B; ++b) {
    int mt = (1 << b) - 1;
    for (int is = 0; is < MX / 2; is++) {
      int i1 = (is & mt);
      int i = i1 + ((is ^ i1) << 1);
      i1 = i ^ (mt + 1);
      a[i] = a[i] + a[i1];
      a[i1] = a[i] - a[i1] - a[i1];
    }
  }
  for (int i = 0; i < MX; ++i) {
    a[i] = (a[i] % MOD + MOD) % MOD;
  }
  if (rev) {
    for (int i = 0; i < MX; ++i) {
      a[i] = (a[i] * _MX) % MOD;
    }
  }
}
ll a[MX], b[MX], res[MX], ways[MX];
void xor_convolution() {
  conv(a, 0);
  conv(b, 0);
  for (int i = 0; i < MX; ++i) {
    res[i] = (a[i] * b[i]) % MOD;
  }
  conv(res, 1);
  for (int i = 0; i < MX; ++i) {
    res[i] %= MOD;
  }
}
void init() {
  fill(res, res + MX, 0);
  res[0] = 1;
}
void handle_cycle(vector<int> &cycle) {
  fill(b, b + MX, 0);
  swap(a, res);
  fill(res, res + MX, 0);
  for (auto x : cycle) {
    b[x]++;
  }
  xor_convolution();
}
void go() {
  init();
  for (auto c : cycles) {
    handle_cycle(c);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  g.resize(n);
  for (int i = 0; i < m; ++i) {
    int u, v, w;
    cin >> u >> v >> w;
    u--;
    v--;
    g[u].emplace_back(v, w);
    g[v].emplace_back(u, w);
    xr ^= w;
  }
  dfs(0, 0);
  go();
  MOD = 1e9 + 9;
  _MX = inverse(MX);
  for (int i = 0; i < MX; ++i) {
    ways[i] = res[i];
  }
  go();
  int ans = 1e9, cnt = 0;
  for (int i = 0; i < MX; ++i) {
    if (res[i] || ways[i]) {
      if (ans > (i ^ xr)) {
        ans = (i ^ xr);
        cnt = ways[i];
      }
    }
  }
  cout << ans << " " << cnt << endl;
  return 0;
}