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;
namespace TYC {
const int MAXN = 1 << 17, N = MAXN + 5;
int ecnt = 1, scc, Head[N], dfn[N], low[N], tag[N << 1];
struct edge {
  int to, next, w;
} E[N << 1];
vector<int> node[N];
inline int read() {
  int x = 0, f = 0, ch = getchar();
  while (!isdigit(ch)) f |= (ch == '-'), ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return f ? -x : x;
}
inline void add(const int u, const int v, const int w) {
  E[++ecnt] = (edge){v, Head[u], w};
  Head[u] = ecnt;
}
void Tarjan(const int u, const int pre) {
  static int tim, top, sta[N], in[N];
  sta[++top] = u;
  dfn[u] = low[u] = ++tim;
  for (int i = Head[u]; i; i = E[i].next)
    if ((i ^ 1) != pre) {
      int v = E[i].to;
      if (!dfn[v])
        Tarjan(v, i), low[u] = min(low[u], low[v]);
      else if (!in[v])
        low[u] = min(low[u], dfn[v]);
    }
  if (low[u] == dfn[u]) {
    ++scc;
    do node[scc].push_back(sta[top--]);
    while (sta[top + 1] != u);
  }
}
void solve(int *val, const vector<int> &p) {
  static int w[N];
  int sz = p.size(), sum = 0;
  for (int k = 0; k < sz; k++) {
    int u = p[k], v = p[(k + 1) % sz];
    for (int i = Head[u]; i; i = E[i].next)
      if (E[i].to == v) {
        w[k] = E[i].w;
        tag[i] = tag[i ^ 1] = 1;
        break;
      }
    sum ^= w[k];
  }
  for (int i = 0; i < sz; i++) ++val[sum ^ w[i]];
}
template <const int mod>
struct ModFWT {
  void FWT(int *a, const int n = MAXN) {
    for (int len = 1; len < n; len <<= 1)
      for (int i = 0; i < n; i += len << 1)
        for (int k = 0; k < len; k++) {
          int x = a[i + k], y = a[i + len + k];
          a[i + k] = (x + y) % mod;
          a[i + len + k] = (x - y + mod) % mod;
        }
  }
  void IFWT(int *a, const int n = MAXN) {
    int INV2 = (mod + 1) >> 1;
    for (int len = 1; len < n; len <<= 1)
      for (int i = 0; i < n; i += len << 1)
        for (int k = 0; k < len; k++) {
          int x = a[i + k], y = a[i + len + k];
          a[i + k] = (long long)(x + y) * INV2 % mod;
          a[i + len + k] = (long long)(x - y + mod) % mod * INV2 % mod;
        }
  }
  void mul(const int *A, const int *B, int *c) {
    static int a[N], b[N];
    memcpy(a, A, sizeof(a));
    memcpy(b, B, sizeof(b));
    FWT(a), FWT(b);
    for (int i = 0; i < MAXN; i++) c[i] = (long long)a[i] * b[i] % mod;
    IFWT(c);
  }
};
ModFWT<1000000007> Mod1;
ModFWT<1000000009> Mod2;
void work() {
  int n = read(), m = read();
  for (int i = 1; i <= m; i++) {
    int u = read(), v = read(), w = read();
    add(u, v, w), add(v, u, w);
  }
  Tarjan(1, 0);
  static int A[N], B[N], tmp[N];
  for (int i = 1, flag = 0; i <= scc; i++)
    if (node[i].size() > 1) {
      memset(tmp, 0, sizeof(tmp));
      solve(tmp, node[i]);
      if (!flag) {
        flag = 1;
        memcpy(A, tmp, sizeof(A));
        memcpy(B, tmp, sizeof(B));
      } else {
        Mod1.mul(A, tmp, A);
        Mod2.mul(B, tmp, B);
      }
    }
  int sum = 0, ans = 0x3f3f3f3f;
  for (int i = 2; i <= ecnt; i += 2)
    if (!tag[i]) sum ^= E[i].w;
  for (int i = 0; i < MAXN; i++)
    if (A[i] || B[i]) ans = min(ans, sum ^ i);
  printf("%d %d\n", ans, A[ans ^ sum]);
}
}  // namespace TYC
int main() {
  TYC::work();
  return 0;
}