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>
int read() {
  register int x = 0;
  register char f = 1, ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f ^= 1;
  for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ '0');
  return f ? x : -x;
}
namespace Fast_Walsh_Transform {
int plus(int a, int b) { return (a += b) >= 1000000007 ? a - 1000000007 : a; }
int minus(int a, int b) { return (a -= b) < 0 ? a + 1000000007 : a; }
void FWT_xor(std ::vector<int> &a, int op = 1) {
  int n = a.size();
  for (register int m = 1; m < n; m <<= 1)
    for (register int l = m << 1, p = 0; p < n; p += l)
      for (register int i = p; i < p + m; ++i) {
        int t0 = plus(a[i], a[i + m]), t1 = minus(a[i], a[i + m]);
        if (~op)
          a[i] = t0, a[i + m] = t1;
        else
          a[i] = 1ll * t0 * 500000004 % 1000000007,
          a[i + m] = 1ll * t1 * 500000004 % 1000000007;
      }
}
std ::vector<int> mul_xor(std ::vector<int> a, std ::vector<int> b) {
  int n = a.size();
  FWT_xor(a), FWT_xor(b);
  for (register int i = 0; i < n; ++i) a[i] = 1ll * a[i] * b[i] % 1000000007;
  FWT_xor(a, -1);
  return a;
}
}  // namespace Fast_Walsh_Transform
using Fast_Walsh_Transform ::mul_xor;
int n, m, cnt, mw, sw;
std ::vector<int> cyc[50];
std ::vector<int> ans_ex, ans;
int edge, to[100055 << 1], tw[100055 << 1], pr[100055 << 1], hd[100055];
void addedge(int u, int v, int w) {
  to[++edge] = v, tw[edge] = w, pr[edge] = hd[u], hd[u] = edge;
}
int top, sta[100055], stw[100055], vis[100055];
void dfs(int u, int fa = 0, int fw = 0) {
  sta[++top] = u, stw[top] = fw, vis[u] = 2;
  for (register int i = hd[u], v; i; i = pr[i])
    if ((v = to[i]) != fa) {
      int w = tw[i];
      if (!vis[v])
        dfs(v, u, w);
      else if (vis[v] == 2) {
        int k = top;
        while (sta[k] != v) --k;
        ++cnt;
        for (register int i = k + 1; i <= top; ++i) cyc[cnt].push_back(stw[i]);
        cyc[cnt].push_back(w);
      }
    }
  vis[u] = 1, --top;
}
int get(int n) {
  int res = 1;
  while (res < n) res <<= 1;
  return res;
}
int main() {
  n = read(), m = read();
  for (register int i = 1, u, v, w; i <= m; ++i) {
    u = read(), v = read(), w = read(), sw ^= w, mw = std ::max(mw, w);
    addedge(u, v, w), addedge(v, u, w);
  }
  mw = get(mw + 1);
  dfs(1);
  ans.resize(mw), ans[sw] = 1;
  ans_ex.resize(mw), ans_ex[sw] = 1;
  for (register int i = 1; i <= cnt; ++i) {
    std ::vector<int> tmp(mw);
    for (int v : cyc[i]) ++tmp[v];
    ans = mul_xor(ans, tmp);
    ans_ex = mul_xor(ans_ex, tmp);
    for (register int j = 0; j < mw; ++j)
      if (ans_ex[j]) ans_ex[j] = 1;
  }
  for (register int i = 0; i < mw; ++i)
    if (ans_ex[i]) return printf("%d %d\n", i, ans[i]), 0;
}