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;
struct edge {
  int to, cost;
  edge(int a, int b) { to = a, cost = b; }
};
int n, m;
vector<edge> G[100005];
vector<pair<int, int> > pvec;
vector<int> vec[45];
int pedge[100005];
int sum;
long long inv2;
long long dp[1 << 17], dp2[1 << 17], a[1 << 17];
int tour;
int order[100005];
int Prev[100005][17];
int depth[100005];
int N = 1 << 17;
long long mod = 1000000007;
int id = 1;
void dfs(int v, int p, int d) {
  order[v] = id++;
  Prev[v][0] = p, depth[v] = d;
  for (int i = 0; i < G[v].size(); i++) {
    if (G[v][i].to == p) {
      pedge[v] = i;
      continue;
    }
    if (order[G[v][i].to]) {
      if (order[G[v][i].to] < order[v]) pvec.push_back(make_pair(v, i));
      continue;
    }
    dfs(G[v][i].to, v, d + 1);
  }
}
int getLCA(int u, int v) {
  int x = u, y = v;
  if (depth[y] > depth[x]) swap(x, y);
  for (int i = 16; i >= 0; i--) {
    if (depth[x] - (1 << i) >= depth[y]) x = Prev[x][i];
  }
  if (x == y) return x;
  for (int i = 16; i >= 0; i--) {
    if (Prev[x][i] != Prev[y][i]) {
      x = Prev[x][i];
      y = Prev[y][i];
    }
  }
  x = Prev[x][0];
  return x;
}
void fwt(long long f[], int n) {
  int N = 1 << n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < N; j++) {
      if (j & (1 << i)) continue;
      long long x = f[j], y = f[j | (1 << i)];
      f[j] = (x + y) % mod, f[j | (1 << i)] = (x - y + mod) % mod;
    }
  }
}
void ifwt(long long f[], int n) {
  int N = 1 << n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < N; j++) {
      if (j & (1 << i)) continue;
      long long x = f[j], y = f[j | (1 << i)];
      f[j] = (x + y) * inv2 % mod, f[j | (1 << i)] = (x - y + mod) * inv2 % mod;
    }
  }
}
long long modpow(long long a, long long n) {
  if (n == 0) return 1;
  if (n % 2) {
    return ((a % mod) * (modpow(a, n - 1) % mod)) % mod;
  } else {
    return modpow((a * a) % mod, n / 2) % mod;
  }
}
void calc() {
  for (int i = 0; i < N; i++) dp[i] = 0;
  dp[sum] = 1;
  fwt(dp, 17);
  for (int i = 1; i <= tour; i++) {
    for (int j = 0; j < N; j++) a[j] = 0;
    for (int j = 0; j < vec[i].size(); j++) a[vec[i][j]]++;
    fwt(a, 17);
    for (int j = 0; j < N; j++) dp[j] *= a[j], dp[j] %= mod;
  }
  ifwt(dp, 17);
}
int main(void) {
  clock_t stime = clock();
  inv2 = modpow(2, mod - 2);
  scanf("%d %d", &n, &m);
  int u, v, w;
  sum = 0;
  for (int i = 1; i <= m; i++) {
    scanf("%d %d %d", &u, &v, &w);
    G[u].push_back(edge(v, w));
    G[v].push_back(edge(u, w));
    sum ^= w;
  }
  pedge[1] = -1;
  dfs(1, 0, 0);
  for (int i = 1; i <= 16; i++) {
    for (int j = 1; j <= n; j++) {
      Prev[j][i] = Prev[Prev[j][i - 1]][i - 1];
    }
  }
  int id = 1;
  for (int i = 0; i < pvec.size(); i++) {
    int u = pvec[i].first, v = G[u][pvec[i].second].to;
    vec[id].push_back(G[u][pvec[i].second].cost);
    int lca = getLCA(u, v);
    int p = u;
    while (p != lca) {
      vec[id].push_back(G[p][pedge[p]].cost);
      p = G[p][pedge[p]].to;
    }
    p = v;
    while (p != lca) {
      vec[id].push_back(G[p][pedge[p]].cost);
      p = G[p][pedge[p]].to;
    }
    id++;
  }
  tour = id - 1;
  calc();
  for (int i = 0; i < N; i++) dp2[i] = dp[i];
  mod = 998244853, inv2 = modpow(2, mod - 2);
  calc();
  for (int i = 0; i < N; i++) {
    if (dp[i] || dp2[i]) {
      printf("%d %I64d", i, dp2[i]);
      return 0;
    }
  }
  return 0;
}