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>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
clock_t start_time = clock();
void bad(string mes = "Impossible") {
  cout << mes;
  exit(0);
}
void bad(int mes) {
  cout << mes;
  exit(0);
}
template <typename T>
string bin(T x, int st = 2) {
  string ans = "";
  while (x > 0) {
    ans += char('0' + x % st);
    x /= st;
  }
  reverse(ans.begin(), ans.end());
  return ans.empty() ? "0" : ans;
}
template <typename T>
void upmax(T& x, T y) {
  x = max(x, y);
}
template <typename T>
void upmin(T& x, T y) {
  x = min(x, y);
}
template <typename T>
T input() {
  T ans = 0, m = 1;
  char c = ' ';
  while (!((c >= '0' && c <= '9') || c == '-')) {
    c = getchar();
  }
  if (c == '-') m = -1, c = getchar();
  while (c >= '0' && c <= '9') {
    ans = ans * 10 + (c - '0'), c = getchar();
  }
  return ans * m;
}
template <typename T>
void read(T& a) {
  a = input<T>();
}
template <typename T>
void read(T& a, T& b) {
  read(a), read(b);
}
template <typename T>
void read(T& a, T& b, T& c) {
  read(a, b), read(c);
}
template <typename T>
void read(T& a, T& b, T& c, T& d) {
  read(a, b), read(c, d);
}
const int inf = 1e9 + 20;
const short short_inf = 3e4 + 20;
const long double eps = 1e-6;
const int maxn = (int)2e5 + 12;
const long long llinf = 2e18 + 5;
const double PI = acos(-1.0);
const int mod = 1e9 + 7;
const int mod2 = 1e9 + 9;
template <typename T>
T binpow(T n, T second) {
  if (second <= 0) return 1LL;
  if (second % 2 == 0) {
    T b = binpow(n, second / 2);
    return (1LL * b * b) % mod;
  } else {
    return (1LL * binpow(n, second - 1) * n) % mod;
  }
}
vector<int> tmp;
int used[200000];
vector<vector<int>> kek;
vector<int> st;
vector<pair<int, int>> g[maxn];
map<pair<int, int>, int> sot;
int getEdge(int u, int v) { return sot[minmax(u, v)]; }
void dfs(int v, int p = -1) {
  used[v] = 2;
  st.push_back(v);
  for (auto [to, w] : g[v]) {
    if (to == p) continue;
    if (used[to] == 2) {
      tmp.clear();
      for (int i = st.size() - 1; st[i] != to; i--) {
        tmp.push_back(getEdge(st[i], st[i - 1]));
      }
      tmp.push_back(w);
      kek.push_back(tmp);
    } else if (used[to] == 0) {
      dfs(to, v);
    }
  }
  st.pop_back();
  used[v] = 1;
}
int poly[45][140000];
int poly2[45][140000];
void transform(int id, int from, int to) {
  if (to - from == 1) return;
  int mid = from + (to - from) / 2;
  transform(id, from, mid);
  transform(id, mid, to);
  for (int i = 0; i < mid - from; i++) {
    int a = poly[id][from + i];
    int b = poly[id][mid + i];
    poly[id][from + i] = (a + b) % mod;
    poly[id][mid + i] = ((a - b) % mod + mod) % mod;
    a = poly2[id][from + i];
    b = poly2[id][mid + i];
    poly2[id][from + i] = (a + b) % mod2;
    poly2[id][mid + i] = ((a - b) % mod2 + mod2) % mod2;
  }
}
int inv(int x) { return binpow(x, mod - 2); }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  int x = 0;
  for (int i = 0; i < m; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    u--, v--;
    g[u].push_back({v, w});
    g[v].push_back({u, w});
    sot[minmax(u, v)] = w;
    x ^= w;
  }
  for (int i = 0; i < n; i++)
    if (!used[i]) dfs(i);
  assert(kek.size() < 43);
  if (kek.size() == 0) {
    cout << x << ' ' << 1 << endl;
    return 0;
  }
  for (int i = 0; i < kek.size(); i++) {
    for (int j : kek[i]) {
      poly[i][j]++;
      poly2[i][j]++;
    }
    transform(i, 0, (1 << 17));
    for (int j = 0; j < (1 << 17); j++) {
      if (i == 0)
        poly[43][j] = poly[i][j];
      else {
        poly[43][j] = 1ll * poly[43][j] * poly[i][j] % mod;
      }
    }
    for (int j = 0; j < (1 << 17); j++) {
      if (i == 0)
        poly2[43][j] = poly2[i][j];
      else {
        poly2[43][j] = 1ll * poly2[43][j] * poly2[i][j] % mod2;
      }
    }
  }
  transform(43, 0, (1 << 17));
  int re = mod, mda;
  for (int i = 0; i < (1 << 17); i++) {
    if (poly[43][i] || poly2[43][i]) {
      poly[43][i] = 1ll * poly[43][i] * inv(1 << 17) % mod;
      if ((i ^ x) < re) {
        re = i ^ x;
        mda = poly[43][i];
      }
    }
  }
  cout << re << ' ' << mda;
  return 0;
}