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 oo = 2139063143;
const int N = 501000;
const double eps = 1e-7;
template <typename T>
inline void sc(T &x) {
  x = 0;
  static int p;
  p = 1;
  static char c;
  c = getchar();
  while (!isdigit(c)) {
    if (c == '-') p = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c - 48);
    c = getchar();
  }
  x *= p;
}
template <typename T>
inline void print(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}
template <typename T>
inline void pr(T x) {
  print(x), putchar('\n');
}
template <typename T1, typename T2>
void chkmax(T1 &A, T2 B) {
  A = A >= B ? A : B;
}
template <typename T1, typename T2>
void chkmin(T1 &A, T2 B) {
  A = A <= B ? A : B;
}
const int P1 = 1e9 + 7, P2 = 1e9 + 9;
int del(int x, int P) { return x >= P ? x - P : x; }
void fwt(int *a, int n, bool op, const int P) {
  const int inv2 = (P + 1) >> 1;
  for (int i = 1; i < n; i <<= 1)
    for (int j = 0, sb = i << 1; j < n; j += sb)
      for (int k = j; k < j + i; k++) {
        int x = a[k], y = a[k + i];
        a[k] = del(x + y, P), a[k + i] = del(x - y + P, P);
        if (!op)
          a[k] = (long long)a[k] * inv2 % P,
          a[k + i] = (long long)a[k + i] * inv2 % P;
      }
}
struct EDGE {
  int v, w, id, nx;
} lb[N << 1];
int tot = 1, top[N];
void add(int u, int v, int w, int id) {
  lb[++tot] = (EDGE){v, w, id, top[u]}, top[u] = tot;
}
int fa[N], d[N], dep[N];
bool vis[N], in[N];
void dfs(int u) {
  vis[u] = 1;
  for (int kb = top[u]; kb; kb = lb[kb].nx) {
    int v = lb[kb].v, w = lb[kb].w, id = lb[kb].id;
    if (vis[v]) continue;
    in[id] = 1;
    dep[v] = dep[u] + 1, fa[v] = u, d[v] = w;
    dfs(v);
  }
}
int n, m, x[N], y[N], w[N], a[N], b[N], c[N], e[N];
int main() {
  sc(n), sc(m);
  int S = 0, ma = 0;
  for (int i = 1; i <= m; i++) {
    sc(x[i]), sc(y[i]), sc(w[i]);
    add(x[i], y[i], w[i], i), add(y[i], x[i], w[i], i);
    S ^= w[i];
    chkmax(ma, w[i]);
  }
  int s = 1;
  while (s <= ma) s <<= 1;
  a[0] = 1, c[0] = 1;
  fwt(a, s, 1, P1), fwt(c, s, 1, P2);
  dfs(1);
  for (int i = 1; i <= m; i++)
    if (!in[i]) {
      int x = ::x[i], y = ::y[i], w = ::w[i];
      memset(b, 0, sizeof(int) * (s + 1));
      ++b[w];
      while (x != y) {
        if (dep[x] < dep[y]) swap(x, y);
        ++b[d[x]];
        x = fa[x];
      }
      memcpy(e, b, sizeof(int) * (s + 1));
      fwt(b, s, 1, P1), fwt(e, s, 1, P2);
      for (int i = 0; i < s; i++)
        a[i] = (long long)a[i] * b[i] % P1, c[i] = (long long)c[i] * e[i] % P2;
    }
  fwt(a, s, 0, P1), fwt(c, s, 0, P2);
  int mi = 1e9, ans = 0;
  for (int i = 0; i < s; i++)
    if (a[i] || c[i]) {
      int g = S ^ i;
      if (mi > g) mi = g, ans = a[i];
    }
  printf("%d %d\n", mi, ans);
  return 0;
}