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;
int pw(int a, int b, int M) {
  int r = 1;
  while (b) {
    if (b & 1) r = (long long)r * a % M;
    a = (long long)a * a % M;
    b /= 2;
  }
  return r;
}
int inv(int a, int M) { return pw(a, M - 2, M); }
const int M = (int)1e9 + 7;
const int M2 = (int)1e9 + 123123;
const int A = (1 << 17);
const int IA1 = inv(A, M), IA2 = inv(A, M2);
void fft(vector<pair<int, int>> &a) {
  for (int l = 2; l <= A; l *= 2) {
    for (int i = 0; i < A; i += l) {
      for (int j = 0; j < l / 2; j++) {
        int x = a[i + j].first + a[i + l / 2 + j].first,
            y = a[i + j].first - a[i + l / 2 + j].first;
        if (x >= M) x -= M;
        if (y < 0) y += M;
        a[i + j].first = x;
        a[i + l / 2 + j].first = y;
        x = a[i + j].second + a[i + l / 2 + j].second,
        y = a[i + j].second - a[i + l / 2 + j].second;
        if (x >= M2) x -= M2;
        if (y < 0) y += M2;
        a[i + j].second = x;
        a[i + l / 2 + j].second = y;
      }
    }
  }
}
void fftrev(vector<pair<int, int>> &a) {
  for (int l = 2; l <= A; l *= 2) {
    for (int i = 0; i < A; i += l) {
      for (int j = 0; j < l / 2; j++) {
        int x = a[i + j].first + a[i + l / 2 + j].first,
            y = a[i + j].first - a[i + l / 2 + j].first;
        if (x >= M) x -= M;
        if (y < 0) y += M;
        a[i + j].first = x;
        a[i + l / 2 + j].first = y;
        x = a[i + j].second + a[i + l / 2 + j].second,
        y = a[i + j].second - a[i + l / 2 + j].second;
        if (x >= M2) x -= M2;
        if (y < 0) y += M2;
        a[i + j].second = x;
        a[i + l / 2 + j].second = y;
      }
    }
  }
  for (auto &x : a) {
    x.first = (long long)x.first * IA1 % M;
    x.second = (long long)x.second * IA2 % M2;
  }
}
vector<pair<int, int>> xorConvolution(vector<pair<int, int>> a,
                                      vector<pair<int, int>> b) {
  fft(a);
  fft(b);
  for (int i = 0; i < A; i++) {
    a[i].first = (long long)a[i].first * b[i].first % M;
    a[i].second = (long long)a[i].second * b[i].second % M2;
  }
  fftrev(a);
  return a;
}
const int N = (int)1e5 + 7;
int n, m, dep[N];
vector<pair<int, int>> ret(A, {0, 0});
vector<int> wghs;
vector<pair<int, int>> g[N];
void dfs(int a) {
  for (auto &it : g[a]) {
    int b = it.first, w = it.second;
    if (dep[b] == -1) {
      dep[b] = 1 + dep[a];
      wghs.push_back(w);
      dfs(b);
      wghs.pop_back();
      continue;
    }
    if (dep[b] < dep[a] - 1) {
      vector<pair<int, int>> f(A, {0, 0});
      f[w].first++;
      f[w].second = 1;
      for (int j = (int)wghs.size() - (dep[a] - dep[b]); j < (int)wghs.size();
           j++) {
        f[wghs[j]].first++;
        f[wghs[j]].second = 1;
      }
      ret = xorConvolution(ret, f);
    }
  }
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ret[0] = {1, 1};
  cin >> n >> m;
  for (int i = 1; i <= n; i++) dep[i] = -1;
  int totalXor = 0;
  for (int i = 1; i <= m; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    totalXor ^= z;
    g[x].push_back({y, z});
    g[y].push_back({x, z});
  }
  dep[1] = 0;
  dfs(1);
  for (int j = 0; j < A; j++) {
    if (ret[j ^ totalXor].second) {
      cout << j << " " << ret[j ^ totalXor].first << "\n";
      return 0;
    }
  }
}