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;
struct edge {
  int v, w;
};
vector<edge> g[200001];
int dfn[200001], low[200001], bel[200001], dfc, bcc;
int bcs[200001], *bct = bcs;
void bcc_clr(int n) { fill(dfn + 1, dfn + n + 1, 0); }
int dfs_bcc(int u, int f) {
  *bct++ = u;
  dfn[u] = low[u] = ++dfc;
  for (edge e : g[u]) {
    int v = e.v;
    if (v == f) continue;
    if (!dfn[v])
      low[u] = min(low[u], dfs_bcc(v, u));
    else
      low[u] = min(low[u], low[v]);
  }
  if (dfn[u] == low[u])
    for (++bcc; *bct != u; --bct) bel[bct[-1]] = bcc;
  return low[u];
}
struct edge0 {
  int u, v, w;
} es[200001];
long long a[200001], b[200001], a1[200001], b1[200001];
void fwt(long long* a, int n, long long P) {
  for (int k = 1; k < n; k <<= 1)
    for (int m = k << 1, i = 0; i < n; i += m)
      for (int j = 0; j != k; j++) {
        long long x = a[i + j], y = a[i + j + k];
        a[i + j] = (((x + y) + P) % P);
        a[i + j + k] = (((x - y) + P) % P);
      }
}
void ifwt(long long* a, int n, long long P) {
  for (int k = 1; k < n; k <<= 1)
    for (int m = k << 1, i = 0; i < n; i += m)
      for (int j = 0; j != k; j++) {
        long long x = a[i + j], y = a[i + j + k];
        a[i + j] = ((((((x + y) + P) % P) * ((P + 1) / 2)) + P) % P);
        a[i + j + k] = ((((((x - y) + P) % P) * ((P + 1) / 2)) + P) % P);
      }
}
int main(void) {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) {
    int u, v, w;
    scanf("%d%d%d", &u, &v, &w);
    es[i] = {u, v, w};
    g[u].push_back({v, w});
    g[v].push_back({u, w});
  }
  dfs_bcc(1, 0);
  int c = m - n + 1;
  map<int, vector<int>> sv;
  int sum = 0, cnt = 0;
  for (int i = 1; i <= m; ++i) {
    if (bel[es[i].u] != bel[es[i].v])
      sum ^= es[i].w;
    else
      sv[bel[es[i].u]].push_back(es[i].w);
  }
  int w = 1 << 17, t = 0;
  for (const pair<int, vector<int>>& p : sv) {
    int xs = 0;
    for (int x : p.second) xs ^= x;
    if (t == 0) {
      for (int x : p.second) a[sum ^ xs ^ x]++;
      for (int x : p.second) a1[sum ^ xs ^ x]++;
      fwt(a, w, 1000000007);
      fwt(a1, w, 1145140019);
    } else {
      fill(b, b + w, 0);
      fill(b1, b1 + w, 0);
      for (int x : p.second) b[xs ^ x]++;
      for (int x : p.second) b1[xs ^ x]++;
      fwt(b, w, 1000000007);
      fwt(b1, w, 1145140019);
      for (int i = 0; i != w; ++i) a[i] = a[i] * b[i] % 1000000007;
      for (int i = 0; i != w; ++i) a1[i] = a1[i] * b1[i] % 1145140019;
    }
    ++t;
  }
  if (!c) {
    printf("%d %d", sum, 1);
  } else {
    ifwt(a, w, 1000000007);
    ifwt(a1, w, 1145140019);
    int v = 0;
    while (!a[v] && !a1[v]) ++v;
    printf("%d %lld", v, a[v]);
  }
  return 0;
}