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;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int K = 2;
const long long MODS[K] = {(long long)1e9 + 7, (long long)1e9 + 9};
struct Num {
  long long x[K];
  Num() : x() {}
  Num(long long z) {
    for (int i = 0; i < K; i++) x[i] = ((z % MODS[i]) + MODS[i]) % MODS[i];
  }
  Num operator+(const Num &A) const {
    Num R = Num();
    for (int i = 0; i < K; i++) {
      R.x[i] = x[i] + A.x[i];
      if (R.x[i] >= MODS[i]) R.x[i] -= MODS[i];
    }
    return R;
  }
  Num operator-(const Num &A) const {
    Num R = Num();
    for (int i = 0; i < K; i++) {
      R.x[i] = x[i] - A.x[i];
      if (R.x[i] < 0) R.x[i] += MODS[i];
    }
    return R;
  }
  Num operator*(const Num &A) const {
    Num R = Num();
    for (int i = 0; i < K; i++) {
      R.x[i] = (x[i] * A.x[i]) % MODS[i];
    }
    return R;
  }
};
const int L = 17;
const int N = (1 << L) + 3;
int ed[N][3];
int n, m;
vector<int> g[N];
int par[N];
int h[N];
bool usedEd[N];
int xorAll;
Num A[N], B[N];
void FFT(Num *C) {
  for (int k = 0; k < L; k++)
    for (int mask = 0; mask < (1 << L); mask++) {
      if ((mask >> k) & 1) continue;
      Num x = C[mask], y = C[mask ^ (1 << k)];
      C[mask] = x + y;
      C[mask ^ (1 << k)] = x - y;
    }
}
int getOther(int id, int v) { return ed[id][0] ^ ed[id][1] ^ v; }
void addCycle(int id) {
  vector<int> all;
  int v = ed[id][0], u = ed[id][1];
  if (h[v] < h[u]) swap(v, u);
  all.push_back(id);
  while (v != u) {
    id = par[v];
    all.push_back(id);
    v = getOther(id, v);
  }
  for (int i = 0; i < (1 << L); i++) B[i] = Num(0);
  for (int id : all) {
    usedEd[id] = 1;
    int x = ed[id][2];
    B[x] = B[x] + Num(1);
  }
  FFT(B);
  for (int i = 0; i < (1 << L); i++) A[i] = A[i] * B[i];
}
void dfs(int v) {
  42;
  for (int id : g[v]) {
    if (id == par[v]) continue;
    int u = getOther(id, v);
    if (par[u] == -1) {
      if (usedEd[id]) throw;
      par[u] = id;
      h[u] = h[v] + 1;
      dfs(u);
    } else {
      if (usedEd[id]) continue;
      addCycle(id);
    }
  }
}
int main() {
  A[0] = Num(1);
  FFT(A);
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < 3; j++) scanf("%d", &ed[i][j]);
    ed[i][0]--;
    ed[i][1]--;
    g[ed[i][0]].push_back(i);
    g[ed[i][1]].push_back(i);
    xorAll ^= ed[i][2];
  }
  for (int i = 0; i < n; i++) par[i] = -1;
  par[0] = -2;
  dfs(0);
  FFT(A);
  int bst = N;
  long long cnt = 0;
  for (int mask = 0; mask < (1 << L); mask++) {
    bool bad = true;
    for (int i = 0; i < K; i++) bad &= A[mask].x[i] == 0;
    if (bad) continue;
    int m2 = mask ^ xorAll;
    if (m2 < bst) {
      bst = m2;
      cnt = A[mask].x[0];
    }
  }
  for (int i = 0; i < L; i++) {
    if (cnt & 1) cnt += MODS[0];
    cnt /= 2;
  }
  printf("%d %lld\n", bst, cnt);
  return 0;
}