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 N = (1 << 17);
const int mod = 1e9 + 7;
int add(int a, int b) {
  a += b;
  if (a >= mod) a -= mod;
  return a;
}
int sub(int a, int b) {
  a -= b;
  if (a < 0) a += mod;
  return a;
}
int mul(int a, int b) { return 1ll * a * b % mod; }
int Pow(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = mul(ans, a);
    a = mul(a, a);
    b >>= 1;
  }
  return ans;
}
vector<pair<int, int> > g[N];
vector<pair<int, int> > path;
int F[50][N];
int P[50][N];
int v[N];
int tot = 0;
void dfs(int u, int p) {
  if (v[u] > 1) return;
  if (v[u] > 0) {
    for (int j = (int)path.size() - 1; j >= 0; --j) {
      int x = path[j].first;
      int w = path[j].second;
      F[tot][w]++;
      P[tot][w] = 1;
      if (x == u) break;
    }
    ++tot;
    return;
  }
  v[u] = 1;
  for (pair<int, int> e : g[u])
    if (e.first != p) {
      int v = e.first;
      int w = e.second;
      path.emplace_back(u, w);
      dfs(v, u);
      path.pop_back();
    }
  v[u] = 2;
}
void fft(int *f, bool inv) {
  for (int k = 1; k < N; k <<= 1)
    for (int i = 0; i < N; i += k * 2)
      for (int j = 0; j < k; ++j) {
        int x = f[i + j];
        int y = f[i + j + k];
        f[i + j] = add(x, y);
        f[i + j + k] = sub(x, y);
      }
  if (inv) {
    for (int i = 0; i < N; ++i) f[i] = mul(f[i], Pow(N, mod - 2));
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int m;
  cin >> m;
  assert(n + 42 >= m);
  int Sum = 0;
  for (int i = 0; i < m; ++i) {
    int x;
    cin >> x;
    int y;
    cin >> y;
    int w;
    cin >> w;
    g[x].emplace_back(y, w);
    g[y].emplace_back(x, w);
    Sum ^= w;
  }
  dfs(1, 0);
  fill(F[tot], F[tot] + N, 1);
  fill(P[tot], P[tot] + N, 1);
  for (int i = 0; i < tot; ++i) {
    fft(F[i], 0);
    fft(P[i], 0);
    for (int j = 0; j < N; ++j)
      F[tot][j] = mul(F[tot][j], F[i][j]), P[tot][j] = mul(P[tot][j], P[i][j]);
  }
  fft(F[tot], 1);
  fft(P[tot], 1);
  int ans = mod;
  int res = 0;
  for (int i = 0; i < N; ++i)
    if (F[tot][i] || P[tot][i]) {
      int nxt = (Sum ^ i);
      if (ans > nxt) {
        ans = nxt;
        res = F[tot][i];
      }
    }
  cout << ans << " ";
  cout << res << endl;
}