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 MOD = 1e9 + 7;
int MOD2 = 998244353;
int INF = 1e18;
const int L = 17;
const int N = (1 << L);
vector<int> gr[N];
vector<int> gr2[N];
int kol_c = 0;
int comp[N];
int h[N];
int used[N];
int dfs(int v, int pr) {
  h[v] = h[pr] + 1;
  int an = MOD;
  for (auto i : gr[v]) {
    if (!h[i]) {
      an = min(an, dfs(i, v));
    } else {
      if (i != pr) an = min(an, h[i]);
    }
  }
  comp[v] = (an >= h[v]);
  return an;
}
void cm(int v, int kol) {
  if (comp[v])
    comp[v] = ++kol_c;
  else
    comp[v] = kol;
  used[v] = 1;
  for (auto i : gr[v]) {
    if (!used[i]) {
      cm(i, comp[v]);
    }
  }
}
vector<int> num[N];
vector<int> cnt, cnt2;
vector<int> cnt_, cnt2_;
int binpow(int x, int y) {
  if (!y) return 1;
  if (y % 2) return (1ll * (long long)x * (long long)binpow(x, y - 1)) % MOD;
  return binpow((1ll * (long long)x * (long long)x) % MOD, y / 2);
}
int revers(int x) { return binpow(x % MOD, MOD - 2); }
void adamar(vector<int> &a, int l, int r) {
  if (l + 1 >= r) return;
  int mid = (r + l) / 2;
  adamar(a, l, mid);
  adamar(a, mid, r);
  for (int i = l; i < mid; i++) {
    int u = a[i], v = a[i + mid - l];
    a[i] = (u + v) % MOD;
    a[i + mid - l] = (u - v) % MOD;
  }
}
void andamar(vector<int> &a, int l, int r) {
  if (l + 1 >= r) return;
  int mid = (r + l) / 2;
  andamar(a, l, mid);
  andamar(a, mid, r);
  for (int i = l; i < mid; i++) a[i] = (a[i] + a[i + mid - l]) % MOD;
}
void revandamar(vector<int> &a, int l, int r) {
  if (l + 1 >= r) return;
  int mid = (r + l) / 2;
  revandamar(a, l, mid);
  revandamar(a, mid, r);
  for (int i = l; i < mid; i++) a[i] = (a[i] - a[i + mid - l]) % MOD;
}
void ordamar(vector<int> &a, int l, int r) {
  if (l + 1 >= r) return;
  int mid = (r + l) / 2;
  ordamar(a, l, mid);
  ordamar(a, mid, r);
  for (int i = l; i < mid; i++) a[i + mid - l] = (a[i] + a[i + mid - l]) % MOD;
}
void revordamar(vector<int> &a, int l, int r) {
  if (l + 1 >= r) return;
  int mid = (r + l) / 2;
  revordamar(a, l, mid);
  revordamar(a, mid, r);
  for (int i = l; i < mid; i++) a[i + mid - l] = (-a[i] + a[i + mid - l]) % MOD;
}
vector<int> xormult(vector<int> a, vector<int> b) {
  adamar(a, 0, a.size());
  adamar(b, 0, b.size());
  for (int i = 0; i < a.size(); i++)
    a[i] = (1ll * (long long)a[i] * (long long)b[i]) % MOD;
  adamar(a, 0, a.size());
  int revn = revers(a.size());
  for (int i = 0; i < a.size(); i++)
    a[i] = (1ll * (long long)a[i] * (long long)revn) % MOD;
  return a;
}
int binpow2(int x, int y) {
  if (!y) return 1;
  if (y % 2) return (1ll * (long long)x * (long long)binpow2(x, y - 1)) % MOD2;
  return binpow2((1ll * (long long)x * (long long)x) % MOD2, y / 2);
}
int revers2(int x) { return binpow2(x % MOD2, MOD2 - 2); }
void adamar2(vector<int> &a, int l, int r) {
  if (l + 1 >= r) return;
  int mid = (r + l) / 2;
  adamar2(a, l, mid);
  adamar2(a, mid, r);
  for (int i = l; i < mid; i++) {
    int u = a[i], v = a[i + mid - l];
    a[i] = (u + v) % MOD2;
    a[i + mid - l] = (u - v) % MOD2;
  }
}
void andamar2(vector<int> &a, int l, int r) {
  if (l + 1 >= r) return;
  int mid = (r + l) / 2;
  andamar2(a, l, mid);
  andamar2(a, mid, r);
  for (int i = l; i < mid; i++) a[i] = (a[i] + a[i + mid - l]) % MOD2;
}
void revandamar2(vector<int> &a, int l, int r) {
  if (l + 1 >= r) return;
  int mid = (r + l) / 2;
  revandamar2(a, l, mid);
  revandamar2(a, mid, r);
  for (int i = l; i < mid; i++) a[i] = (a[i] - a[i + mid - l]) % MOD2;
}
void ordamar2(vector<int> &a, int l, int r) {
  if (l + 1 >= r) return;
  int mid = (r + l) / 2;
  ordamar2(a, l, mid);
  ordamar2(a, mid, r);
  for (int i = l; i < mid; i++) a[i + mid - l] = (a[i] + a[i + mid - l]) % MOD2;
}
void revordamar2(vector<int> &a, int l, int r) {
  if (l + 1 >= r) return;
  int mid = (r + l) / 2;
  revordamar2(a, l, mid);
  revordamar2(a, mid, r);
  for (int i = l; i < mid; i++)
    a[i + mid - l] = (-a[i] + a[i + mid - l]) % MOD2;
}
vector<int> xormult2(vector<int> a, vector<int> b) {
  adamar2(a, 0, a.size());
  adamar2(b, 0, b.size());
  for (int i = 0; i < a.size(); i++)
    a[i] = (1ll * (long long)a[i] * (long long)b[i]) % MOD2;
  adamar2(a, 0, a.size());
  int revn = revers2(a.size());
  for (int i = 0; i < a.size(); i++)
    a[i] = (1ll * (long long)a[i] * (long long)revn) % MOD2;
  return a;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0),
      cout << fixed << setprecision(20);
  int n, m;
  cin >> n >> m;
  int x = 0;
  for (int i = 0; i < m; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    x ^= w;
    u--, v--;
    gr[u].push_back(v);
    gr2[u].push_back(w);
    gr[v].push_back(u);
    gr2[v].push_back(w);
  }
  dfs(0, 0);
  cm(0, 0);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < gr[i].size(); j++) {
      int to = gr[i][j];
      int w = gr2[i][j];
      if (i > to && comp[i] == comp[to]) {
        num[comp[i]].push_back(w);
      }
    }
  }
  cnt.assign(N, 0);
  cnt_.assign(N, 0);
  cnt[x] = 1;
  cnt_[x] = 1;
  for (int ii = 0; ii < N; ii++) {
    if (num[ii].size()) {
      cnt2.assign(N, 0);
      cnt2_.assign(N, 0);
      for (auto j : num[ii]) {
        cnt2[j]++;
        cnt2_[j]++;
      }
      cnt = xormult(cnt, cnt2);
      cnt_ = xormult2(cnt_, cnt2_);
      for (int i = 0; i < N; i++) {
        cnt[i] %= MOD;
        cnt_[i] %= MOD2;
        if (cnt[i] < 0) {
          cnt[i] += MOD;
        }
        if (cnt_[i] < 0) {
          cnt_[i] += MOD2;
        }
      }
    }
  }
  for (int i = 0; i < N; i++) {
    if (cnt[i] || cnt_[i]) {
      cout << i << " " << cnt[i];
      break;
    }
  }
}