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;
using ll = long long;
using ld = double;
const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;
int n, m, visited[MAXN], low[MAXN], num[MAXN], dfsNum;
stack<pair<pair<int, int>, int> > s;
vector<pair<int, int> > a[MAXN];
vector<vector<int> > group;
ll MOD = MODBASE;
ll MOD2 = 77886769;
ll binPowMod(ll a, ll b, ll mod) {
  a %= mod;
  ll res = 1;
  while (b > 0) {
    if (b & 1LL) res = res * a % mod;
    a = a * a % mod;
    b >>= 1LL;
  }
  return res;
}
void dfs(int u, int p) {
  num[u] = low[u] = ++dfsNum;
  visited[u] = 1;
  for (pair<int, int> x : a[u]) {
    int v = x.first, c = x.second;
    if (v == p) continue;
    if (num[v] == 0) {
      s.push(pair<pair<int, int>, int>(pair<int, int>(u, v), c));
      dfs(v, u);
      low[u] = min(low[u], low[v]);
      if (low[v] >= num[u]) {
        pair<pair<int, int>, int> r;
        vector<int> g;
        do {
          r = s.top();
          s.pop();
          g.push_back(r.second);
        } while (r.first != pair<int, int>(u, v) &&
                 r.first != pair<int, int>(v, u));
        if (int((g).size()) > 1) group.push_back(g);
      }
    } else {
      if (num[v] < num[u])
        s.push(pair<pair<int, int>, int>(pair<int, int>(u, v), c));
      low[u] = min(low[u], num[v]);
    }
  }
}
void FWHT(vector<int> &P, bool inverse, ll mod, int revN) {
  int n = int((P).size());
  for (int len = 1; 2 * len <= n; len <<= 1) {
    for (int i = 0; i < n; i += 2 * len) {
      for (int j = (0); j <= (len - 1); j++) {
        int u = P[i + j];
        int v = P[i + len + j];
        P[i + j] = (u + v) % mod;
        P[i + len + j] = (u - v + mod) % mod;
      }
    }
  }
  if (inverse)
    for (int i = (0); i <= (n - 1); i++) P[i] = (ll)P[i] * revN % mod;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(nullptr);
  cin >> n >> m;
  int sumXor = 0;
  for (int i = (1); i <= (m); i++) {
    int u, v, c;
    cin >> u >> v >> c;
    a[u].push_back(pair<int, int>(v, c));
    a[v].push_back(pair<int, int>(u, c));
    sumXor ^= c;
  }
  dfs(1, 0);
  int N = (1 << 17);
  int revN = binPowMod(N, MOD - 2, MOD);
  int revN2 = binPowMod(N, MOD2 - 2, MOD2);
  vector<int> res(N), res2(N);
  res[0] = 1;
  res2[0] = 1;
  FWHT(res, 0, MOD, revN);
  FWHT(res2, 0, MOD2, revN2);
  for (int i = (0); i <= (int((group).size()) - 1); i++) {
    vector<int> b(N, 0);
    for (int j = (0); j <= (int((group[i]).size()) - 1); j++) b[group[i][j]]++;
    FWHT(b, 0, MOD, revN);
    for (int j = (0); j <= (N - 1); j++) res[j] = (ll)res[j] * b[j] % MOD;
    vector<int> c(N, 0);
    for (int j = (0); j <= (int((group[i]).size()) - 1); j++) c[group[i][j]]++;
    FWHT(c, 0, MOD2, revN2);
    for (int j = (0); j <= (N - 1); j++) res2[j] = (ll)res2[j] * c[j] % MOD2;
  }
  FWHT(res, 1, MOD, revN);
  FWHT(res2, 1, MOD2, revN2);
  int Min = 1000000, cnt = 0;
  for (int i = (0); i <= (N - 1); i++) {
    if (res[i] == 0 && res2[i] == 0) continue;
    if ((sumXor ^ i) < Min) {
      Min = sumXor ^ i;
      cnt = res[i];
    }
  }
  cout << Min << ' ' << cnt;
  return 0;
}