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;
int mod = 1e9 + 7;
int read() {
  int x = 0, F = 1;
  char d = getchar();
  while (d < '0' || d > '9') {
    if (d == '-') F = -1;
    d = getchar();
  }
  while (d >= '0' && d <= '9') x = (x << 1) + (x << 3) + d - '0', d = getchar();
  return x * F;
}
int qpow(int a, int x, int mo) {
  int res = 1;
  while (x) {
    if (x & 1) res = 1ll * res * a % mo;
    x >>= 1;
    a = 1ll * a * a % mo;
  }
  return res;
}
int inc(int x, int y, int mo) {
  if (y < 0) y += mo;
  if (x + y >= mo) x -= mo;
  return x + y;
}
int Inv2;
void FWT(int *A, int n, int op, int t) {
  for (int i = 2; i <= n; i <<= 1) {
    for (int j = 0, mid = i >> 1; j < n; j += i)
      for (int k = 0; k < mid; k++) {
        if (t == 1)
          A[j + mid + k] = inc(A[j + mid + k], A[j + k] * op, mod);
        else if (t == 2)
          A[j + k] = inc(A[j + k], A[j + mid + k] * op, mod);
        else if (t == 3) {
          int x = A[j + k], y = A[j + mid + k];
          if (op == 1)
            A[j + k] = (x + y) % mod, A[j + mid + k] = (x - y + mod) % mod;
          else
            A[j + k] = 1ll * Inv2 * (x + y) % mod,
                  A[j + mid + k] = 1ll * Inv2 * (x - y + mod) % mod;
        }
      }
  }
}
void FWTX(int *A, int *B, int n, int t) {
  Inv2 = qpow(2, mod - 2, mod);
  FWT(B, n, 1, t);
  for (int i = 0; i < n; ++i) A[i] = 1ll * A[i] * B[i] % mod;
}
vector<pair<int, int> > g[N];
int dfn[N];
int vis[N], fa[N], fw[N];
int a[N], b[N], g1[N], g2[N];
void dfs(int x) {
  vis[x] = 1;
  dfn[x] = dfn[fa[x]] + 1;
  for (pair<int, int> now : g[x]) {
    int v = now.first;
    int w = now.second;
    if (v == fa[x]) continue;
    if (vis[v] && dfn[v] < dfn[x]) {
      memset(a, 0, sizeof(a));
      memset(b, 0, sizeof(b));
      int sum = w;
      int f = x;
      a[w]++;
      b[w]++;
      while (f != v) a[fw[f]]++, b[fw[f]]++, f = fa[f];
      mod = 1e9 + 7;
      FWTX(g1, a, 1 << 17, 3);
      mod = 998244353;
      FWTX(g2, b, 1 << 17, 3);
    } else if (vis[v] == 0) {
      fa[v] = x;
      fw[v] = w;
      dfs(v);
    }
  }
}
int main() {
  int n = read(), m = read();
  int sum = 0;
  for (int i = 1; i <= m; i++) {
    int u = read(), v = read(), w = read();
    g[u].push_back(make_pair(v, w));
    g[v].push_back(make_pair(u, w));
    sum ^= w;
  }
  g1[sum] = 1;
  g2[sum] = 1;
  mod = 1e9 + 7;
  Inv2 = qpow(2, mod - 2, mod);
  FWT(g1, 1 << 17, 1, 3);
  mod = 998244353;
  Inv2 = qpow(2, mod - 2, mod);
  FWT(g2, 1 << 17, 1, 3);
  dfs(1);
  mod = 1e9 + 7;
  Inv2 = qpow(2, mod - 2, mod);
  FWT(g1, 1 << 17, -1, 3);
  mod = 998244353;
  Inv2 = qpow(2, mod - 2, mod);
  FWT(g2, 1 << 17, -1, 3);
  for (int i = 0; i < (1 << 17); i++) {
    if (g1[i] || g2[i]) {
      printf("%d %d\n", i, g1[i]);
      return 0;
    }
  }
}