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 maxn = 1e5 + 5;
const int maxv = 1 << 17;
const double eps = 1e-7;
struct FWT {
  const static int mod = 1e9 + 7, inv2 = 5e8 + 4;
  int sz = 0;
  int add(int x, int y) { return ((x + y) % mod + mod) % mod; }
  int mul(int x, int y) { return (1LL * x * y) % mod; }
  void FWTxor(int *p, int inv) {
    for (int len = 1; 2 * len <= sz; len <<= 1) {
      for (int i = 0; i < sz; i += 2 * len) {
        for (int j = 0; j < len; j++) {
          int x = p[i + j], y = p[i + j + len];
          p[i + j] = add(x, y);
          p[i + j + len] = add(x, -y);
          if (inv) {
            p[i + j] = mul(p[i + j], inv2);
            p[i + j + len] = mul(p[i + j + len], inv2);
          }
        }
      }
    }
  }
  void FWTxor(double *p, int inv) {
    for (int len = 1; 2 * len <= sz; len <<= 1) {
      for (int i = 0; i < sz; i += 2 * len) {
        for (int j = 0; j < len; j++) {
          double x = p[i + j], y = p[i + j + len];
          p[i + j] = x + y;
          p[i + j + len] = x - y;
          if (inv) {
            p[i + j] = p[i + j] / 2;
            p[i + j + len] = p[i + j + len] / 2;
          }
        }
      }
    }
  }
} fwt;
int n, m;
vector<int> way[maxn];
map<int, map<int, int>> edge;
int cur, low[maxn], num[maxn];
stack<int> st;
int id, vec[45][maxv + 5];
int ans[maxv + 5];
double vec2[45][maxv + 5];
double ans2[maxv + 5];
void tarjan(int u, int last) {
  low[u] = num[u] = ++cur;
  st.push(u);
  for (auto v : way[u]) {
    if (v == last) continue;
    if (!num[v]) {
      tarjan(v, u);
      low[u] = min(low[u], low[v]);
    } else
      low[u] = min(low[u], num[v]);
  }
  if (num[u] == low[u]) {
    vector<int> have;
    while (!st.empty()) {
      int x = st.top();
      st.pop();
      have.push_back(x);
      if (x == u) break;
    }
    if (have.size() > 1) {
      id++;
      have.push_back(have[0]);
      int sz = have.size();
      for (int i = 1; i < sz; i++) {
        vec[id][edge[have[i]][have[i - 1]]]++;
        vec2[id][edge[have[i]][have[i - 1]]] = 1;
      }
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  int sum = 0;
  for (int i = 1; i <= m; i++) {
    int u, v, val;
    scanf("%d%d%d", &u, &v, &val);
    way[u].push_back(v);
    way[v].push_back(u);
    edge[u][v] = edge[v][u] = val;
    sum = sum ^ val;
  }
  for (int u = 1; u <= n; u++)
    if (!num[u]) tarjan(u, 0);
  fwt.sz = maxv;
  ans[sum] = 1;
  fwt.FWTxor(ans, 0);
  ans2[sum] = 1;
  fwt.FWTxor(ans2, 0);
  for (int x = 1; x <= id; x++) {
    fwt.FWTxor(vec[x], 0);
    fwt.FWTxor(vec2[x], 0);
    for (int i = 0; i < maxv; i++) {
      ans[i] = fwt.mul(ans[i], vec[x][i]);
      ans2[i] = ans2[i] * vec2[x][i];
    }
  }
  fwt.FWTxor(ans, 1);
  fwt.FWTxor(ans2, 1);
  for (int i = 0; i < maxv; i++) {
    if (ans2[i] >= eps) {
      printf("%d %d\n", i, ans[i]);
      return 0;
    }
  }
}