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;
namespace FWT {
int pw(int a, long long int n, int mod) {
  if (n == 0) return 1;
  int q = pw(a, n / 2, mod);
  if (n % 2 == 0) return q * 1ll * q % mod;
  return q * 1ll * q % mod * a % mod;
}
void fwt(vector<int>& a, bool inv, int op, int mod, int n = 1) {
  while (a.size() > n) n <<= 1;
  int I2 = pw(2, mod - 2, mod);
  for (int i = 1; 2 * i <= n; i <<= 1) {
    for (int j = 0; j < n; j += 2 * i) {
      for (int k = 0; k < i; k++) {
        int x = a[j + k];
        int y = a[i + j + k];
        if (!inv) {
          if (op == 1)
            a[j + k] = (x + y) % mod, a[i + j + k] = (x - y + mod) % mod;
          if (op == 2) a[j + k] = (x + y) % mod;
          if (op == 3) a[i + j + k] = (x + y) % mod;
        } else {
          if (op == 1)
            a[j + k] = 1ll * I2 * (x + y) % mod,
                  a[i + j + k] = 1ll * I2 * (x - y + mod) % mod;
          if (op == 2) a[j + k] = (x - y + mod) % mod;
          if (op == 3) a[i + j + k] = (y - x + mod) % mod;
        }
      }
    }
  }
}
vector<int> multiply(vector<int>& a, vector<int>& b, int op, int mod) {
  int n = 1;
  while (a.size() > n || b.size() > n) n <<= 1;
  fwt(a, 0, op, mod, n);
  fwt(b, 0, op, mod, n);
  vector<int> res(n);
  for (int i = 0; i < n; i++) {
    res[i] = a[i] * 1ll * b[i] % mod;
  }
  fwt(res, 1, op, mod, n);
  return res;
}
}  // namespace FWT
struct Edge {
  int u, v, c;
};
vector<Edge> backEdges;
vector<pair<int, int> > adj[100005];
vector<int> cycle[45];
int vs[100005], h[100005], p[100005], edgeLen[100005];
void dfs(int u) {
  vs[u] = 1;
  for (auto i : adj[u]) {
    if (i.first == p[u]) continue;
    if (vs[i.first]) {
      if (u < i.first) backEdges.push_back({u, i.first, i.second});
    } else {
      p[i.first] = u;
      h[i.first] = h[u] + 1;
      edgeLen[i.first] = i.second;
      dfs(i.first);
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  int xorAll = 0;
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int u, v, c;
    cin >> u >> v >> c;
    adj[u].push_back({v, c});
    adj[v].push_back({u, c});
    xorAll ^= c;
  }
  h[1] = 1;
  dfs(1);
  int numCycle = 0;
  for (auto e : backEdges) {
    int curU = e.u, curV = e.v;
    numCycle++;
    cycle[numCycle].push_back(e.c);
    if (h[curU] > h[curV]) swap(curU, curV);
    while (h[curV] > h[curU]) {
      cycle[numCycle].push_back(edgeLen[curV]);
      curV = p[curV];
    }
    while (curU != curV) {
      cycle[numCycle].push_back(edgeLen[curU]);
      cycle[numCycle].push_back(edgeLen[curV]);
      curU = p[curU];
      curV = p[curV];
    }
  }
  vector<int> a[45], b[45];
  const int MAXN = (1 << 17);
  const int MOD = 1e9 + 7;
  const int MOD2 = 77886769;
  for (int i = 0; i <= numCycle; i++) {
    a[i].resize(MAXN);
    b[i].resize(MAXN);
  }
  for (int i = 1; i <= numCycle; i++) {
    for (auto j : cycle[i]) {
      a[i][j]++;
      b[i][j]++;
    }
  }
  a[0][0] = 1;
  b[0][0] = 1;
  for (int i = 0; i <= numCycle; i++) {
    FWT::fwt(a[i], 0, 1, MOD, MAXN);
    FWT::fwt(b[i], 0, 1, MOD2, MAXN);
  }
  for (int i = 1; i <= numCycle; i++) {
    for (int j = 0; j <= MAXN - 1; j++) {
      a[0][j] = a[0][j] * 1ll * a[i][j] % MOD;
      b[0][j] = b[0][j] * 1ll * b[i][j] % MOD2;
    }
  }
  FWT::fwt(a[0], 1, 1, MOD, MAXN);
  FWT::fwt(b[0], 1, 1, MOD2, MAXN);
  int minVal = 1000000000;
  int cnt = 0;
  for (int i = 0; i <= MAXN - 1; i++) {
    if (!a[0][i] && !b[0][i]) continue;
    if (minVal > (i ^ xorAll)) {
      minVal = i ^ xorAll;
      cnt = a[0][i];
    }
  }
  cout << minVal << " " << cnt << endl;
  return 0;
}