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 std::abs;
using std::array;
using std::cerr;
using std::cin;
using std::cout;
using std::generate;
using std::get;
using std::make_pair;
using std::make_tuple;
using std::map;
using std::max;
using std::max_element;
using std::min;
using std::min_element;
using std::pair;
using std::reverse;
using std::set;
using std::sort;
using std::string;
using std::swap;
using std::tuple;
using std::unique;
using std::vector;
template <typename T>
T input() {
  T res;
  cin >> res;
  {};
  return res;
}
template <typename IT>
void input_seq(IT b, IT e) {
  std::generate(b, e,
                input<typename std::remove_reference<decltype(*b)>::type>);
}
struct edge_t {
  int to;
  int w;
};
int fpow(int a, int n, int mod, int r = 1) {
  while (n) {
    if (n % 2) r = (int64_t(r) * a) % mod;
    a = (int64_t(a) * a) % mod;
    n /= 2;
  }
  return r;
}
void fft(int k, vector<int>& arr, int mod) {
  for (int lvl = 0; lvl < k; ++lvl)
    for (int off = 0; off < (1 << k); off += (2 << lvl))
      for (int pos = 0; pos < (1 << lvl); ++pos) {
        int a = arr[off + pos];
        int b = arr[off + pos + (1 << lvl)];
        arr[off + pos] = (a + b >= mod ? a + b - mod : a + b);
        arr[off + pos + (1 << lvl)] = (a >= b ? a - b : mod + a - b);
      }
}
int main() {
  std::iostream::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n, m;
  cin >> n >> m;
  vector<vector<edge_t>> graph(n);
  int base = 0;
  for (int i = 0; i != m; ++i) {
    int v, u, w;
    cin >> v >> u >> w;
    --v, --u;
    graph[v].emplace_back(edge_t{u, w});
    graph[u].emplace_back(edge_t{v, w});
    base ^= w;
  }
  vector<edge_t> up(n, edge_t{-1, -1});
  vector<char> used(n, 0);
  vector<vector<int>> lists;
  std::function<void(int, edge_t)> dfs = [&](int v, edge_t p) {
    up[v] = p;
    used[v] = 1;
    for (auto u : graph[v])
      if (used[u.to] == 0) {
        dfs(u.to, edge_t{v, u.w});
      } else if (used[u.to] == 1 and u.to != p.to) {
        vector<int> list = {u.w};
        for (int w = v; w != u.to; w = up[w].to) list.push_back(up[w].w);
        int xr = 0;
        for (int elem : list) xr ^= elem;
        base ^= xr;
        for (int& elem : list) elem ^= xr;
        lists.push_back(list);
      }
    used[v] = 2;
  };
  dfs(0, edge_t{-10, -10});
  lists.push_back(vector<int>{base});
  int mod = int(1e9) + 993;
  int m2 = int(1e9) + 7;
  vector<int> arr(1 << 17, 1);
  vector<int> arr2(1 << 17, 1);
  for (auto& el : lists) {
    vector<int> r1(1 << 17), r2(1 << 17);
    for (int v : el) {
      r1[v] += 1;
      r2[v] += 1;
    }
    fft(17, r1, mod);
    fft(17, r2, m2);
    for (int i = 0; i != (1 << 17); ++i) {
      arr[i] = (int64_t(arr[i]) * r1[i]) % mod;
      arr2[i] = (int64_t(arr2[i]) * r2[i]) % m2;
    }
  }
  fft(17, arr, mod);
  fft(17, arr2, m2);
  int minpos = 0;
  while (arr[minpos] == 0 and arr2[minpos] == 0) ++minpos;
  cout << minpos << " " << fpow(1 << 17, m2 - 2, m2, arr2[minpos]) << "\n";
  return 0;
}