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>
int d_, x_, y_;
void gcd_(int a, int b) {
  if (b == 0)
    d_ = a, x_ = 1, y_ = 0;
  else {
    int tmp;
    gcd_(b, a % b);
    tmp = x_ - a / b * y_, x_ = y_, y_ = tmp;
  }
}
int inv(int a) {
  gcd_(a, 1000000007);
  if (x_ < 0) x_ += 1000000007;
  return x_;
}
void wht(int *aa) {
  int h, i;
  for (h = 0; h < 17; h++)
    for (i = 0; i < (1 << 17); i++)
      if ((i & 1 << h) == 0) {
        int j = i ^ 1 << h, u = aa[i], v = aa[j];
        if ((aa[i] = u + v) >= 1000000007) aa[i] -= 1000000007;
        if ((aa[j] = u - v) < 0) aa[j] += 1000000007;
      }
}
int aa[(1 << 17)], can[(1 << 17)];
void mult(int *bb) {
  int i;
  wht(bb);
  for (i = 0; i < (1 << 17); i++) aa[i] = (long long)aa[i] * bb[i] % 1000000007;
  wht(can);
  for (i = 0; i < (1 << 17); i++)
    can[i] = (long long)can[i] * bb[i] % 1000000007;
  wht(can);
  for (i = 0; i < (1 << 17); i++)
    if (can[i]) can[i] = 1;
}
int oo[1 + 100041 * 2], oh[1 + 100041 * 2];
int link(int o, int h) {
  static int _ = 1;
  oo[_] = o, oh[_] = h;
  return _++;
}
int ij[100041], ww[100041];
int ae[100000], ff[100000], ta[100000];
void dfs(int f, int i) {
  static int bb[(1 << 17)];
  static int time;
  int o;
  ta[i] = ++time;
  ff[i] = f;
  for (o = ae[i]; o; o = oo[o]) {
    int h = oh[o];
    if (h != f) {
      int j = i ^ ij[h];
      if (!ta[j])
        dfs(h, j);
      else if (ta[j] < ta[i]) {
        int i_ = i;
        memset(bb, 0, sizeof bb);
        bb[ww[h]]++;
        while (i_ != j) {
          h = ff[i_];
          bb[ww[h]]++;
          i_ ^= ij[h];
        }
        mult(bb);
      }
    }
  }
}
int main() {
  int n, m, h, x, y, y_;
  long long v;
  scanf("%d%d", &n, &m);
  x = 0;
  for (h = 0; h < m; h++) {
    int i, j, w;
    scanf("%d%d%d", &i, &j, &w), i--, j--;
    ij[h] = i ^ j, ww[h] = w;
    ae[i] = link(ae[i], h);
    ae[j] = link(ae[j], h);
    x ^= w;
  }
  aa[0] = 1, can[0] = 1;
  wht(aa);
  dfs(-1, 0);
  wht(aa);
  v = inv((1 << 17));
  for (y = 0; y < (1 << 17); y++) aa[y] = aa[y] * v % 1000000007;
  y_ = 0;
  for (y = 1; y < (1 << 17); y++)
    if (can[y] && (y_ ^ x) > (y ^ x)) y_ = y;
  printf("%d %d\n", y_ ^ x, aa[y_]);
  return 0;
}