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 inf = 1e9;
const long long inf64 = 1e18;
const int mod = inf + 7;
inline int _sum(int a, int b) { return a + b < mod ? a + b : a + b - mod; }
inline int _mul(int a, int b) { return (1ll * a * b) % mod; }
inline int _sub(int a, int b) { return a >= b ? a - b : a - b + mod; }
inline void _inc(int& x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}
inline void _dec(int& x, int y) {
  if ((x -= y) < 0) {
    x += mod;
  }
}
inline int _binpow(int x, int pw) {
  int res = 1;
  int tmp = x;
  while (pw > 0) {
    if (pw & 1) {
      res = _mul(res, tmp);
    }
    tmp = _mul(tmp, tmp);
    pw >>= 1;
  }
  return res;
}
inline int _div(int a, int b) { return _mul(a, _binpow(b, mod - 2)); }
int r2;
const int N = 1e5 + 100;
int n, m;
vector<pair<int, int>> g[N];
set<pair<int, int>> br;
void add_bridge(int u, int v) {
  if (u > v) swap(u, v);
  br.insert({u, v});
}
bool is_bridge(int u, int v) {
  if (u > v) swap(u, v);
  return br.count({u, v});
}
int fup[N];
int tin[N], timer;
int used[N];
int xr[N];
vector<int> comp[N];
void dfs(int v, int from = -1) {
  used[v] = 1;
  tin[v] = fup[v] = timer++;
  for (pair<int, int> ed : g[v]) {
    int to = ed.first;
    if (to == from) continue;
    if (used[to]) {
      fup[v] = min(fup[v], tin[to]);
    } else {
      dfs(to, v);
      fup[v] = min(fup[v], fup[to]);
      if (fup[to] > tin[v]) {
        add_bridge(v, to);
      }
    }
  }
}
int color[N];
void go(int v, int cl) {
  color[v] = cl;
  for (pair<int, int> ed : g[v]) {
    int to = ed.first;
    if (is_bridge(v, to)) continue;
    if (!color[to]) {
      go(to, cl);
    }
  }
}
const int LOG = 17;
int _rev[1 << LOG];
void fwht(vector<int>& a) {
  for (int len = 1; len < (1 << LOG); len <<= 1) {
    for (int i = 0; i < (1 << LOG); i += 2 * len) {
      for (int j = 0; j < len; j++) {
        int f1 = _sum(a[i + j], a[i + j + len]);
        int f2 = _sub(a[i + j], a[i + j + len]);
        a[i + j] = f1;
        a[i + j + len] = f2;
      }
    }
  }
}
int main() {
  for (int i = 0; i < (1 << LOG); i++) {
    int j = 0;
    for (int q = 0; q < LOG; q++) {
      if ((1 << q) & i) {
        j |= (1 << (LOG - 1 - q));
      }
    }
    _rev[i] = j;
  }
  r2 = _binpow(1 << LOG, mod - 2);
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int w, u, v, i = 0; i < m; i++) {
    cin >> u >> v >> w;
    g[u].emplace_back(v, w);
    g[v].emplace_back(u, w);
  }
  dfs(1);
  int cl = 0;
  for (int v = 1; v <= n; v++) {
    if (color[v]) continue;
    cl++;
    go(v, cl);
  }
  vector<vector<int>> vals;
  int tot = 0;
  for (int v = 1; v <= n; v++) {
    for (pair<int, int> ed : g[v]) {
      int to = ed.first;
      if (v > to) continue;
      int we = ed.second;
      if (is_bridge(v, to)) {
        tot ^= we;
        continue;
      }
      xr[color[v]] ^= we;
      comp[color[v]].push_back(we);
    }
  }
  for (int c = 1; c <= cl; c++) {
    vector<int> add;
    for (int we : comp[c]) {
      add.push_back(xr[c] ^ we);
    }
    if (!add.empty()) vals.push_back(add);
  }
  vector<int> cur_dp(1 << LOG), cur_can(1 << LOG);
  cur_dp[tot] = 1;
  cur_can[tot] = 1;
  for (const auto& ar : vals) {
    vector<int> tmp_dp(1 << LOG), tmp_can(1 << LOG);
    for (int x : ar) {
      _inc(tmp_dp[x], 1);
      tmp_can[x] = 1;
    }
    fwht(cur_dp);
    fwht(cur_can);
    fwht(tmp_dp);
    fwht(tmp_can);
    vector<int> nxt_dp(1 << LOG), nxt_can(1 << LOG);
    for (int i = 0; i < (1 << LOG); i++) {
      nxt_dp[i] = _mul(cur_dp[i], tmp_dp[i]);
      nxt_can[i] = _mul(cur_can[i], tmp_can[i]);
    }
    fwht(nxt_dp);
    fwht(nxt_can);
    for (int i = 0; i < (1 << LOG); i++) {
      nxt_dp[i] = _mul(nxt_dp[i], r2);
      nxt_can[i] = _mul(nxt_can[i], r2);
    }
    for (int i = 0; i < (int)nxt_can.size(); i++) {
      if (nxt_can[i]) nxt_can[i] = 1;
    }
    cur_dp = nxt_dp;
    cur_can = nxt_can;
  }
  for (int i = 0; i < (int)cur_dp.size(); i++) {
    if (cur_can[i]) {
      cout << i << " " << cur_dp[i] << "\n";
      break;
    }
  }
  return 0;
}