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 <class T, class T1>
int chkmin(T &x, const T1 &y) {
  return x > y ? x = y, 1 : 0;
}
template <class T, class T1>
int chkmax(T &x, const T1 &y) {
  return x < y ? x = y, 1 : 0;
}
const int MAXN = (1 << 20);
int n, m, Xor;
vector<pair<int, int> > adj[MAXN];
void read() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    adj[u].push_back({v, w});
    adj[v].push_back({u, w});
    Xor ^= w;
  }
}
int par[MAXN], par_w[MAXN], d[MAXN];
bool visited[MAXN];
vector<vector<int> > c;
void dfs(int u, int pr) {
  visited[u] = true;
  for (auto e : adj[u]) {
    if (!visited[e.first]) {
      par[e.first] = u;
      par_w[e.first] = e.second;
      d[e.first] = 1 + d[u];
      dfs(e.first, u);
    } else if (pr != e.first && d[e.first] < d[u]) {
      int x = u;
      vector<int> cycle = {e.second};
      do {
        cycle.push_back(par_w[x]);
        x = par[x];
      } while (x != e.first);
      c.push_back(cycle);
    }
  }
}
const int mod = (int)1e9 + 7;
const int inv2 = (mod + 1) / 2;
void fft(int *a, int low, int high) {
  if (high == low + 1) return;
  int len = (high - low) >> 1, mid = low + len;
  fft(a, low, mid);
  fft(a, mid, high);
  for (int i = low; i < mid; i++) {
    int x1 = a[i] % mod;
    int x2 = a[i + len] % mod;
    a[i] = (x1 - x2 + mod) % mod;
    a[i + len] = (x1 + x2) % mod;
  }
}
void inv_fft(int *a, int low, int high) {
  if (high == low + 1) return;
  int len = (high - low) >> 1, mid = low + len;
  for (int i = low; i < mid; i++) {
    int y1 = a[i] % mod;
    int y2 = a[i + len] % mod;
    a[i] = ((y1 + y2) * 1ll * inv2) % mod;
    a[i + len] = ((y2 - y1 + mod) * 1ll * inv2) % mod;
  }
  inv_fft(a, low, mid);
  inv_fft(a, mid, high);
}
const int N = (1 << 17);
int ans[N], tmp[N];
int ok[N];
void solve() {
  dfs(1, -1);
  ans[Xor] = 1;
  ok[Xor] = 1;
  fft(ans, 0, N);
  for (int i = 0; i < ((int)c.size()); i++) {
    memset(tmp, 0, sizeof(tmp));
    for (int v : c[i]) ++tmp[v];
    fft(tmp, 0, N);
    fft(ok, 0, N);
    for (int i = 0; i < N; i++) {
      ans[i] = ans[i] * 1ll * tmp[i] % mod;
      ok[i] = ok[i] * 1ll * tmp[i] % mod;
    }
    inv_fft(ok, 0, N);
    for (int i = 0; i < N; i++) ok[i] = ok[i] != 0;
  }
  inv_fft(ans, 0, N);
  for (int i = 0; i < N; i++) {
    if (ok[i]) {
      cout << i << " " << ans[i] << '\n';
      return;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  read();
  solve();
  return 0;
}