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 = 100000 + 42;
const int V = 1 << 17;
const long long mod7 = 1000000007;
vector<pair<int, int>> g[N];
int used[N];
long long powi(long long a, long long b, long long m) {
  long long c = 1;
  while (b) {
    if (b & 1) c = (c * a) % m;
    a = (a * a) % m;
    b >>= 1;
  }
  return c;
}
void fwht(vector<long long>& a, bool mod = true) {
  for (int j = 1; j < a.size(); j <<= 1) {
    for (int i = 0; i < a.size(); i++) {
      if (i & j) {
        int u = a[i - j];
        int v = a[i];
        a[i - j] = u + v;
        a[i] = u - v;
        if (a[i - j] >= mod7 && mod) a[i - j] -= mod7;
        if (a[i] < 0 && mod) a[i] += mod7;
      }
    }
  }
}
int par[N];
int www[N];
vector<vector<int>> cycles;
void dfs(int v, int p = -1, int ww = 0) {
  www[v] = ww;
  used[v] = true;
  par[v] = p;
  for (pair<int, int> e : g[v]) {
    int to = e.first;
    int w = e.second;
    if (to == p) continue;
    if (!used[to]) {
      dfs(to, v, w);
    } else {
      if (used[to] == 2) continue;
      int ptr = v;
      vector<int> cycle = {w};
      while (ptr != to) {
        used[ptr] = 2;
        cycle.push_back(www[ptr]);
        ptr = par[ptr];
      }
      used[ptr] = 2;
      cycles.emplace_back(move(cycle));
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  int allxor = 0;
  for (int i = 0; i < m; i++) {
    int a, b, w;
    cin >> a >> b >> w;
    a--;
    b--;
    g[a].push_back({b, w});
    g[b].push_back({a, w});
    allxor ^= w;
  }
  dfs(0);
  vector<long long> v(V);
  vector<long long> vv(V);
  v[allxor] = 1;
  vv[allxor] = 1;
  fwht(v);
  fwht(vv, false);
  for (auto cycle : cycles) {
    vector<long long> u(V);
    vector<long long> uu(V);
    for (int c : cycle) u[c]++;
    for (int c : cycle) uu[c] = 1;
    fwht(u);
    fwht(uu, false);
    for (int i = 0; i < V; i++) v[i] = v[i] * u[i] % mod7;
    for (int i = 0; i < V; i++) vv[i] = vv[i] * uu[i];
    fwht(vv, false);
    for (int i = 0; i < V; i++) vv[i] = !!vv[i];
    fwht(vv, false);
  }
  fwht(v);
  fwht(vv, false);
  long long inv = powi(V, mod7 - 2, mod7);
  for (int i = 0; i < V; i++) v[i] = v[i] * inv % mod7;
  for (int i = 0; i < V; i++) {
    if (vv[i]) {
      cout << i << " " << v[i] << endl;
      break;
    }
  }
  return 0;
}