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>
#pragma GCC optimize("Ofast", "unroll-loops")
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using ull = unsigned long long;
using Complex = complex<double>;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
default_random_engine generator;
const int MAXN = 100100;
const int P = 1e9 + 7;
void mul(int &a, int b) { a = (ll)a * b % P; }
void add(int &a, int b) {
  a += b;
  if (a >= P) {
    a -= P;
  }
}
void sub(int &a, int b) {
  a -= b;
  if (a < 0) {
    a += P;
  }
}
int binPow(int a, int b) {
  int res = 1;
  int x = a;
  for (; b > 0; b >>= 1) {
    if (b & 1) {
      mul(res, x);
    }
    mul(x, x);
  }
  return res;
}
vector<int> xorConvolution(vector<int> cur) {
  int n = (int)(cur).size();
  vector<int> ncur(n);
  for (int len = 1; len < n; len <<= 1) {
    for (int pos = 0; pos < n; pos += len) {
      for (int i = 0; i < len; ++pos, ++i) {
        ncur[pos] = cur[pos];
        add(ncur[pos], cur[pos + len]);
        ncur[pos + len] = cur[pos];
        sub(ncur[pos + len], cur[pos + len]);
      }
    }
    cur.swap(ncur);
  }
  return cur;
}
vector<int> xorProduct(vector<int> a, vector<int> b) {
  int n = 1;
  for (; n < max((int)(a).size(), (int)(b).size()); n <<= 1)
    ;
  a.resize(n);
  b.resize(n);
  a = xorConvolution(a);
  b = xorConvolution(b);
  int rn = binPow(n, P - 2);
  for (int i = 0; i < n; ++i) {
    mul(a[i], b[i]);
    mul(a[i], rn);
  }
  return xorConvolution(a);
}
vector<int> g[MAXN];
vector<int> w[MAXN];
vector<int> path;
vector<int> ed;
int x = 0;
vector<vector<int>> block;
int tin[MAXN];
int used[MAXN];
int tim = 0;
int dfs(int v, int p = -1) {
  used[v] = 1;
  tin[v] = tim++;
  path.push_back(v);
  int up = tin[v];
  for (int i = 0; i < (int)(g[v]).size(); ++i) {
    int u = g[v][i];
    if (u == p) {
      continue;
    }
    if (used[u] && tin[u] < tin[v]) {
      up = min(up, tin[u]);
      block.push_back({w[v][i]});
      for (int i = (int)(path).size() - 1; path[i] != u; --i) {
        block.back().push_back(ed[i - 1]);
      }
    }
    if (!used[u]) {
      ed.push_back(w[v][i]);
      int fup = dfs(u, v);
      up = min(up, fup);
      if (fup > tin[v]) {
        x ^= w[v][i];
      }
      ed.pop_back();
    }
  }
  path.pop_back();
  return up;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int u, v, ww;
    cin >> u >> v >> ww;
    --u;
    --v;
    g[u].push_back(v);
    g[v].push_back(u);
    w[u].push_back(ww);
    w[v].push_back(ww);
  }
  dfs(0);
  if ((int)(block).size() == 0) {
    cout << x << " " << 1 << endl;
    return 0;
  }
  for (auto &vct : block) {
    int y = 0;
    for (int el : vct) {
      y ^= el;
    }
    for (int &el : vct) {
      el ^= y;
    }
  }
  for (int &el : block[0]) {
    el ^= x;
  }
  int k = (int)(block).size();
  vector<vector<int>> poly(k, vector<int>(1 << 17));
  vector<vector<int>> poly_cut(k, vector<int>(1 << 17));
  for (int i = 0; i < k; ++i) {
    for (int el : block[i]) {
      ++poly[i][el];
      poly_cut[i][el] |= 1;
    }
  }
  for (int i = 1; i < k; ++i) {
    poly[0] = xorProduct(poly[0], poly[i]);
    poly_cut[0] = xorProduct(poly_cut[0], poly_cut[i]);
    for (int j = 0; j < (1 << 17); ++j) {
      poly_cut[i][j] = (poly_cut[i][j] > 0);
    }
  }
  for (int i = 0; i < (1 << 17); ++i) {
    if (poly_cut[0][i] != 0) {
      cout << i << " " << poly[0][i] << endl;
      return 0;
    }
  }
}