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;
int gcd(int x, int y) { return (!y ? x : gcd(y, x % y)); }
const int maxn = 2e5;
vector<int> g[maxn], tree[maxn];
map<pair<int, int>, int> we;
int par[maxn];
int gpar(int v) { return (par[v] == v ? v : par[v] = gpar(par[v])); }
bool mrg(int u, int v) {
  u = gpar(u);
  v = gpar(v);
  if (u == v) return false;
  par[v] = u;
  return true;
}
int h[maxn];
void dfs(int v, int p) {
  for (auto u : tree[v]) {
    if (u == p) continue;
    par[u] = v;
    h[u] = h[v] + 1;
    dfs(u, v);
  }
}
vector<int> get_path(int u, int v) {
  if (h[u] < h[v]) swap(u, v);
  vector<int> p, rig;
  while (h[u] > h[v]) {
    p.push_back(u);
    u = par[u];
  }
  while (u != v) {
    p.push_back(u);
    rig.push_back(v);
    u = par[u], v = par[v];
  }
  p.push_back(u);
  reverse(rig.begin(), rig.end());
  for (auto i : rig) p.push_back(i);
  return p;
}
const int maxb = 18;
int mods[2] = {int(1e9 + 7), int(1e9 + 9)};
int mod;
const int N = (1 << maxb);
int bpw(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = 1LL * ans * a % mod;
    a = 1LL * a * a % mod;
    b >>= 1;
  }
  return ans;
}
void fwht(int* a, int val) {
  for (int len = 2; len <= N; len *= 2)
    for (int i = 0; i < N; i += len) {
      int nxt = len / 2;
      for (int j = 0; j < nxt; j++) {
        int x = a[i + j], y = a[i + j + nxt];
        a[i + j] = (x + y) % mod;
        a[i + j + nxt] = (x - y + mod) % mod;
      }
    }
  if (val == -1) {
    int inv = bpw(N, mod - 2);
    for (int i = 0; i < N; i++) a[i] = 1LL * a[i] * inv % mod;
  }
}
int ans[2][N], cnt[N];
int32_t main() {
  ios::sync_with_stdio(0), cin.tie(0);
  int n, m;
  cin >> n >> m;
  int tot = 0;
  for (int i = 0; i < m; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    u--, v--;
    g[u].push_back(v);
    g[v].push_back(u);
    we[{u, v}] = we[{v, u}] = w;
    tot ^= w;
  }
  for (int i = 0; i < n; i++) par[i] = i;
  vector<pair<int, int> > bads;
  for (int i = 0; i < n; i++) {
    for (auto j : g[i]) {
      if (mrg(i, j)) {
        tree[i].push_back(j);
        tree[j].push_back(i);
      } else if (i < j)
        bads.push_back({i, j});
    }
  }
  if (bads.size() == 0) {
    cout << tot << " " << 1 << '\n';
    return 0;
  }
  dfs(0, 0);
  for (int it = 0; it < 2; it++) {
    mod = mods[it];
    for (int i = 0; i < N; i++) ans[it][i] = 1;
    for (auto t : bads) {
      vector<int> p = get_path(t.first, t.second);
      p.push_back(p[0]);
      memset(cnt, 0, sizeof cnt);
      for (int i = 0; i + 1 < p.size(); i++) {
        int w = we[{p[i], p[i + 1]}];
        cnt[w]++;
      }
      fwht(cnt, 1);
      for (int i = 0; i < N; i++) ans[it][i] = 1LL * ans[it][i] * cnt[i] % mod;
    }
    fwht(ans[it], -1);
  }
  int jav = 1e9, who = -1;
  for (int i = 0; i < N; i++)
    if (ans[0][i] || ans[1][i]) {
      if ((i ^ tot) < jav) {
        jav = i ^ tot;
        who = i;
      }
    }
  assert(who != -1);
  cout << jav << " " << ans[0][who] << '\n';
}