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;
vector<vector<pair<int, int>>> graph;
vector<vector<int>> cycles;
vector<bool> visited;
vector<int> parent;
vector<int> endpoints;
vector<int> weights;
void dfs(int u, int p) {
  visited[u] = 1;
  parent[u] = p;
  for (auto [v, w] : graph[u]) {
    if (v == parent[u] || v == p) continue;
    weights[v] = w;
    if (visited[v]) {
      endpoints.push_back(u);
      parent[v] = u;
      continue;
    }
    dfs(v, u);
  }
}
int MOD = 1000000007;
int modpow(int b, int e) {
  int a = 1;
  while (e) {
    if (e & 1) a = 1LL * a * b % MOD;
    b = 1LL * b * b % MOD;
    e /= 2;
  }
  return a;
}
struct poly {
  int arr[1 << 17];
  poly() {
    for (int i = 0; i != 1 << 17; ++i) arr[i] = 0;
  }
  int degree() { return (1 << 17); }
  int& operator[](int i) { return arr[i]; }
};
poly FWHT(poly P, bool inverse) {
  for (int len = 1; 2 * len <= P.degree(); len <<= 1) {
    for (int i = 0; i < P.degree(); i += 2 * len) {
      for (int j = 0; j < len; j++) {
        int u = P[i + j];
        int v = P[i + len + j];
        P[i + j] = ((u + v) % MOD + MOD) % MOD;
        P[i + len + j] = ((u - v) % MOD + MOD) % MOD;
      }
    }
  }
  if (inverse) {
    for (int i = 0; i < P.degree(); i++)
      P[i] = 1LL * P[i] * modpow(P.degree(), MOD - 2) % MOD;
  }
  return P;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  int total = 0;
  graph.resize(n);
  for (int i = 0; i != m; ++i) {
    int u, v, w;
    cin >> u >> v >> w;
    u--;
    v--;
    graph[u].push_back({v, w});
    graph[v].push_back({u, w});
    total ^= w;
  }
  visited.resize(n);
  parent.resize(n, -1);
  weights.resize(n);
  dfs(0, -1);
  for (int u : endpoints) {
    cycles.push_back({weights[u]});
    for (int v = parent[u]; v != u; v = parent[v])
      cycles[cycles.size() - 1].push_back(weights[v]);
    ;
  }
  vector<poly> polys(cycles.size());
  for (int i = 0; i != cycles.size(); ++i) {
    for (int v : cycles[i]) polys[i][v]++;
    polys[i] = FWHT(polys[i], 0);
  }
  poly Q = poly();
  for (int i = 0; i != 1 << 17; ++i) Q[i] = 1;
  for (poly& a : polys)
    for (int i = 0; i != 1 << 17; ++i) Q[i] = 1LL * Q[i] * a[i] % MOD;
  Q = FWHT(Q, 1);
  MOD = 998244353;
  polys = vector<poly>(cycles.size());
  for (int i = 0; i != cycles.size(); ++i) {
    for (int v : cycles[i]) polys[i][v]++;
    polys[i] = FWHT(polys[i], 0);
  }
  poly QQ = poly();
  for (int i = 0; i != 1 << 17; ++i) QQ[i] = 1;
  for (poly& a : polys)
    for (int i = 0; i != 1 << 17; ++i) QQ[i] = 1LL * QQ[i] * a[i] % MOD;
  QQ = FWHT(QQ, 1);
  for (int i = 0; i != 1 << 17; ++i) {
    if (Q[i ^ total] || QQ[i ^ total]) {
      cout << i << ' ' << Q[i ^ total] << '\n';
      break;
    }
  }
  return 0;
}