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>
inline long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
inline void sub(long long &a, long long b) {
  a -= b;
  if (a < 0) a += 1000000007;
}
inline void add(long long &a, long long b) {
  a += b;
  if (a >= 1000000007) a -= 1000000007;
}
template <typename T>
inline T const &MAX(T const &a, T const &b) {
  return a > b ? a : b;
}
template <typename T>
inline T const &MIN(T const &a, T const &b) {
  return a < b ? a : b;
}
inline long long mul(long long a, long long b, long long c) {
  return (a * b - (long long)((long double)a * b / c) * c + c) % c;
}
inline long long qp(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % 1000000007;
    a = a * a % 1000000007, b >>= 1;
  }
  return ans;
}
inline long long qp(long long a, long long b, long long c) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = mul(ans, a, c);
    a = mul(a, a, c), b >>= 1;
  }
  return ans;
}
using namespace std;
const long double pi = acos(-1);
const unsigned long long ba = 233;
const double eps = 1e-5;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int N = 100000 + 10, maxn = 2000000 + 10, inf = 0x3f3f3f3f;
int inv = qp(2, 1000000007 - 2, 1000000007),
    inv2 = qp(2, 998244353 - 2, 998244353), len, a[N << 3], b[N << 3],
    aa[N << 3], bb[N << 3];
void fwt_xor(int *a, int n, int dft) {
  for (int i = 1; i < n; i <<= 1)
    for (int j = 0; j < n; j += i << 1)
      for (int k = j; k < j + i; k++) {
        int x = a[k], y = a[i + k];
        a[k] = (x + y) % 1000000007;
        a[i + k] = (x - y + 1000000007) % 1000000007;
        if (dft == -1)
          a[k] = 1ll * a[k] * inv % 1000000007,
          a[i + k] = 1ll * a[i + k] * inv % 1000000007;
      }
}
void fwt_xor2(int *a, int n, int dft) {
  for (int i = 1; i < n; i <<= 1)
    for (int j = 0; j < n; j += i << 1)
      for (int k = j; k < j + i; k++) {
        int x = a[k], y = a[i + k];
        a[k] = (x + y) % 998244353;
        a[i + k] = (x - y + 998244353) % 998244353;
        if (dft == -1)
          a[k] = 1ll * a[k] * inv2 % 998244353,
          a[i + k] = 1ll * a[i + k] * inv2 % 998244353;
      }
}
pair<int, int> pre[N];
bool vis[N];
vector<pair<int, int> > v[N];
map<pair<int, int>, bool> ma;
void dfs(int u, int f) {
  vis[u] = 1;
  for (pair<int, int> x : v[u])
    if (x.first != f && ma.find(make_pair(u, x.first)) == ma.end()) {
      if (vis[x.first]) {
        ma[make_pair(x.first, u)] = 1;
        for (int i = 0; i < len; i++) b[i] = bb[i] = 0;
        b[x.second]++;
        bb[x.second]++;
        for (int now = u; now != x.first; now = pre[now].first)
          b[pre[now].second]++, bb[pre[now].second]++;
        fwt_xor(a, len, 1);
        fwt_xor(b, len, 1);
        fwt_xor2(aa, len, 1);
        fwt_xor2(bb, len, 1);
        for (int i = 0; i < len; i++)
          a[i] = 1ll * a[i] * b[i] % 1000000007,
          aa[i] = 1ll * aa[i] * bb[i] % 998244353;
        fwt_xor(a, len, -1);
        fwt_xor2(aa, len, -1);
      } else
        pre[x.first] = make_pair(u, x.second), dfs(x.first, u);
    }
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int sum = 0;
  for (int i = 1; i <= m; i++) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    v[a].push_back(make_pair(b, c));
    v[b].push_back(make_pair(a, c));
    len = max(len, c);
    sum ^= c;
  }
  int te = 1;
  while (te <= len) te <<= 1;
  len = te;
  a[sum] = aa[sum] = 1;
  dfs(1, 1);
  for (int i = 0; i < len; i++)
    if (a[i] || aa[i]) return 0 * printf("%d %d\n", i, a[i]);
  return 0;
}