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>
std::mt19937 rng(
    (int)std::chrono::steady_clock::now().time_since_epoch().count());
const int ms = 1 << 17;
const int MOD = 1e9 + 7;
const int MOD2 = 1e9 + 9;
int a[2][ms];
int b[2][ms];
void FWHT(int c[ms], int mod, bool inv = false) {
  for (int len = 1; len < ms; len += len) {
    for (int i = 0; i < ms; i += len + len) {
      for (int j = 0; j < len; j++) {
        int u = c[i + j], v = c[i + j + len];
        c[i + j] = (u + v) % mod;
        c[i + j + len] = (u - v + mod) % mod;
      }
    }
  }
  if (inv) {
    int two = (mod + 1) / 2;
    int rev = 1;
    for (int i = 0; i < 17; i++) {
      rev = (long long)rev * two % mod;
    }
    for (int i = 0; i < ms; i++) {
      c[i] = (long long)c[i] * rev % mod;
    }
  }
}
bool visit[ms];
int up[ms], cost[ms];
std::vector<std::pair<int, int>> edges[ms];
std::set<std::pair<int, int>> haha;
void dfs(int on, int par) {
  up[on] = par;
  visit[on] = true;
  for (auto e : edges[on]) {
    std::pair<int, int> hmm(std::min(e.first, on), std::max(e.first, on));
    if (haha.count(hmm)) continue;
    haha.insert(hmm);
    if (visit[e.first]) {
      for (int i = 0; i < ms; i++) {
        b[0][i] = b[1][i] = 0;
      }
      b[0][e.second]++;
      b[1][e.second]++;
      int x = on;
      while (x != e.first) {
        b[0][cost[x]]++;
        b[1][cost[x]]++;
        x = up[x];
      }
      FWHT(b[0], MOD);
      FWHT(b[1], MOD2);
      for (int i = 0; i < ms; i++) {
        a[0][i] = (long long)a[0][i] * b[0][i] % MOD;
        a[1][i] = (long long)a[1][i] * b[1][i] % MOD2;
      }
    } else {
      cost[e.first] = e.second;
      dfs(e.first, on);
    }
  }
}
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);
  for (int i = 0; i < ms; i++) {
    a[0][i] = a[1][i] = 1;
  }
  int n, m;
  std::cin >> n >> m;
  int tot = 0;
  while (m--) {
    int u, v, d;
    std::cin >> u >> v >> d;
    u--;
    v--;
    edges[u].emplace_back(v, d);
    edges[v].emplace_back(u, d);
    tot ^= d;
  }
  dfs(0, -1);
  FWHT(a[0], MOD, true);
  FWHT(a[1], MOD2, true);
  int ans = -1;
  for (int i = 0; i < ms; i++) {
    if (!a[0][i] && !a[1][i]) continue;
    if (ans == -1 || (ans ^ tot) > (i ^ tot)) {
      ans = i;
    }
  }
  std::cout << (tot ^ ans) << ' ' << a[0][ans] << '\n';
}