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,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
using namespace std;
const int MN = 100005, inf = 1000000005, p2 = (1 << 17), C = 50;
const long long INF = 1000000000000000005LL;
int mod;
long long rev;
void trans(vector<long long>& P, bool r) {
  int N = p2;
  for (int len = 1; 2 * len <= N; len <<= 1) {
    for (int i = 0; i < N; i += 2 * len) {
      for (int j = 0; j < len; j++) {
        long long u = P[i + j];
        long long v = P[i + len + j];
        P[i + j] = (u + v);
        P[i + len + j] = (u - v);
      }
    }
  }
  for (int i = 0; i < N; i++) P[i] = ((P[i] % mod) + mod) % mod;
  if (r) {
    for (int i = 0; i < N; i++) P[i] = (P[i] * rev) % mod;
  }
}
long long pot(long long a, long long b) {
  if (b == 0LL) return 1LL;
  long long ret = pot(a, (b >> 1));
  ret = (ret * ret) % mod;
  if (b & 1LL) ret = (ret * a) % mod;
  return ret;
}
int ileCyc;
vector<long long> cyc[2][C];
int used[MN];
vector<int> S, G[MN];
map<pair<int, int>, int> waga;
void dfs(int x, int par) {
  used[x] = 1;
  S.push_back(x);
  for (auto v : G[x])
    if (!used[v]) {
      dfs(v, x);
    } else if (used[v] == 1 && v != par) {
      ++ileCyc;
      cyc[0][ileCyc].resize(p2, 0);
      cyc[1][ileCyc].resize(p2, 0);
      int s = S.size() - 1, cur = v;
      while (1) {
        cyc[0][ileCyc][waga[{S[s], cur}]]++;
        cyc[1][ileCyc][waga[{S[s], cur}]]++;
        cur = S[s];
        --s;
        if (cur == v) break;
      }
    }
  S.pop_back();
  used[x] = 2;
}
void licz(int idx) {
  cyc[idx][0].resize(p2, 0);
  cyc[idx][0][0] = 1LL;
  for (int i = 1; i <= ileCyc; ++i) {
    trans(cyc[idx][i - 1], 0);
    trans(cyc[idx][i], 0);
    for (int j = 0; j < p2; ++j) {
      cyc[idx][i][j] *= cyc[idx][i - 1][j];
      cyc[idx][i][j] %= mod;
    }
    trans(cyc[idx][i], 1);
  }
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  if (n == 1) {
    printf("0 1");
    return 0;
  }
  int ans = 0;
  for (int i = 1; i <= m; ++i) {
    int u, v, w;
    scanf("%d%d%d", &u, &v, &w);
    G[u].push_back(v);
    G[v].push_back(u);
    waga[{u, v}] = waga[{v, u}] = w;
    ans ^= w;
  }
  dfs(1, 0);
  mod = (int)1e9 + 7;
  rev = pot(p2, mod - 2);
  licz(0);
  mod = 999999929;
  rev = pot(p2, mod - 2);
  licz(1);
  int odp = inf, ileOdp = 0;
  for (int i = 0; i < p2; ++i) {
    if (cyc[1][ileCyc][i] == 0) continue;
    int cans = i ^ ans;
    if (cans < odp) {
      odp = cans;
      ileOdp = cyc[0][ileCyc][i];
    }
  }
  printf("%d %d", odp, ileOdp);
}