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 = 1e5 + 100, M = 3e5 + 7;
const long long MOD = 1e9 + 7;
vector<pair<int, int> > p[N];
long long dp[M], gou[M], dp1[M], gou1[M];
int f[N], par[N][20], dep[N], dis[N], u[N], v[N], w[N];
bool vis[N];
vector<int> vec[50];
int find(int x) {
  if (f[x] == x) return x;
  return f[x] = find(f[x]);
}
void dfs(int x, int fa, int r) {
  par[x][0] = fa;
  dep[x] = dep[fa] + 1;
  dis[x] = r;
  for (pair<int, int> v : p[x])
    if (v.first != fa) {
      dfs(v.first, x, v.second);
    }
}
void init(int n) {
  for (int i = 1; i < 20; i++) {
    for (int j = 1; j <= n; j++) {
      par[j][i] = par[par[j][i - 1]][i - 1];
    }
  }
}
int lca(int u, int v) {
  if (dep[u] < dep[v]) swap(u, v);
  for (int i = 19; i >= 0; i--)
    if ((dep[u] - dep[v]) >> i & 1) u = par[u][i];
  if (u == v) return u;
  for (int i = 19; i >= 0; i--)
    if (par[u][i] != par[v][i]) u = par[u][i], v = par[v][i];
  return par[u][0];
}
void fwt(long long a[], int n) {
  for (int d = 1; d < n; d <<= 1) {
    for (int m = d << 1, i = 0; i < n; i += m) {
      for (int j = 0; j < d; j++) {
        long long x = a[i + j], y = a[i + j + d];
        a[i + j] = (x + y) % MOD;
        a[i + j + d] = (x - y + MOD) % MOD;
      }
    }
  }
}
void ifwt(long long a[], int n) {
  int inv2 = (MOD + 1) / 2;
  for (int d = 1; d < n; d <<= 1) {
    for (int m = d << 1, i = 0; i < n; i += m) {
      for (int j = 0; j < d; j++) {
        long long x = a[i + j], y = a[i + j + d];
        a[i + j] = (x + y) * inv2 % MOD;
        a[i + j + d] = (x - y + MOD) * inv2 % MOD;
      }
    }
  }
}
int main() {
  int n, m, n1 = 0;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) f[i] = i;
  int x = 0;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &u[i], &v[i], &w[i]);
    x ^= w[i];
    if (find(u[i]) != find(v[i])) {
      vis[i] = true;
      p[u[i]].push_back({v[i], w[i]});
      p[v[i]].push_back({u[i], w[i]});
      f[find(u[i])] = find(v[i]);
      n1++;
    }
  }
  if (n1 != n - 1) {
    printf("0 0");
    return 0;
  }
  dfs(1, 0, 0);
  init(n);
  int cnt = 0;
  for (int i = 1; i <= m; i++) {
    if (!vis[i]) {
      vec[++cnt].push_back(w[i]);
      int now = u[i], lc = lca(u[i], v[i]);
      while (now != lc) {
        vec[cnt].push_back(dis[now]);
        now = par[now][0];
      }
      now = v[i];
      while (now != lc) {
        vec[cnt].push_back(dis[now]);
        now = par[now][0];
      }
    }
  }
  int t = 131072;
  for (int i = 0; i < t; i++) dp[i] = 0;
  dp[x] = 1;
  fwt(dp, t);
  for (int i = 0; i < t; i++) dp1[i] = dp[i];
  for (int i = 1; i <= cnt; i++) {
    for (int j = 0; j < t; j++) gou[j] = 0, gou1[j] = 0;
    for (int j : vec[i]) gou[j]++, gou1[j] = 1;
    fwt(gou, t);
    fwt(gou1, t);
    for (int j = 0; j < t; j++) {
      dp[j] = dp[j] * gou[j] % MOD;
      dp1[j] = dp1[j] * gou1[j] % MOD;
    }
  }
  ifwt(dp, t);
  ifwt(dp1, t);
  for (int i = 0; i < t; i++) {
    if (dp1[i]) {
      printf("%d %lld\n", i, dp[i]);
      return 0;
    }
  }
  return 0;
}