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;
long long mod = 1000000007LL;
long long large = 2000000000000000000LL;
vector<int> per;
int f(int x) { return x == per[x] ? x : per[x] = f(per[x]); }
vector<vector<pair<int, int> > > adj;
int sz = 17;
vector<int> lv;
vector<pair<int, int> > pa;
void dfs(int u, int parent, int lvl, int w) {
  lv[u] = lvl;
  pa[u] = pair<int, int>(parent, w);
  for (int j = 0; j < (int)adj[u].size(); j++) {
    int v = adj[u][j].first;
    if (v != parent) dfs(v, u, lvl + 1, adj[u][j].second);
  }
}
void get(int u, int v, vector<long long> &a) {
  if (lv[u] < lv[v]) swap(u, v);
  while (lv[u] > lv[v]) {
    a[pa[u].second]++;
    u = pa[u].first;
  }
  while (u != v) {
    a[pa[u].second]++;
    a[pa[v].second]++;
    u = pa[u].first;
    v = pa[v].first;
  }
}
long long rev = (mod + 1) / 2;
void FWT(vector<long long> &a, int sz) {
  int n = (1 << sz);
  for (int d = 1; d < n; d <<= 1)
    for (int m = d << 1, i = 0; i < n; i += m)
      for (int j = 0; j < d; j++) {
        long long x = a[i + j], y = a[i + j + d];
        a[i + j] = (x + y) % mod, a[i + j + d] = (x - y + mod) % mod;
      }
}
void UFWT(vector<long long> &a, int sz) {
  int n = (1 << sz);
  for (int d = 1; d < n; d <<= 1)
    for (int m = d << 1, i = 0; i < n; i += m)
      for (int j = 0; j < d; j++) {
        long long x = a[i + j], y = a[i + j + d];
        a[i + j] = 1LL * (x + y) * rev % mod,
              a[i + j + d] = (1LL * (x - y) * rev % mod + mod) % mod;
      }
}
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  adj.assign(n, vector<pair<int, int> >());
  per.assign(n, -1);
  for (int i = 0; i < n; i++) per[i] = i;
  vector<pair<pair<int, int>, int> > e;
  int ans = 0;
  for (int i = 0; i < m; i++) {
    int x, y, w;
    cin >> x >> y >> w;
    x--;
    y--;
    ans ^= w;
    if (f(x) != f(y)) {
      adj[x].push_back(pair<int, int>(y, w));
      adj[y].push_back(pair<int, int>(x, w));
      per[f(x)] = f(y);
    } else {
      e.push_back(pair<pair<int, int>, int>(pair<int, int>(x, y), w));
    }
  }
  lv.assign(n, -1);
  pa.assign(n, pair<int, int>());
  dfs(0, -1, 0, 0);
  vector<long long> t;
  vector<long long> p;
  vector<long long> a(1 << sz, 0);
  for (int i = 0; i < (int)e.size(); i++) {
    a.assign(1 << sz, 0);
    get(e[i].first.first, e[i].first.second, a);
    a[e[i].second]++;
    vector<long long> b = a;
    for (int j = 0; j < (1 << sz); j++)
      if (a[j]) b[j] = 1;
    FWT(a, sz);
    FWT(b, sz);
    if (t.size() == 0)
      t = a;
    else {
      for (int j = 0; j < (1 << sz); j++) t[j] = t[j] * a[j] % mod;
    }
    if (p.size() == 0)
      p = b;
    else
      for (int j = 0; j < (1 << sz); j++) p[j] = p[j] * b[j] % mod;
  }
  UFWT(t, sz);
  UFWT(p, sz);
  pair<int, int> f = pair<int, int>(1000000000, 0);
  for (int i = 0; i < (1 << sz); i++) {
    if (p[i] > 0) {
      f = min(f, pair<int, int>(i ^ ans, t[i]));
    }
  }
  cout << f.first << " " << f.second << endl;
  return 0;
}