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 comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const int B = 17;
const int MAX = (1 << B) + 10;
int bigMod(int a, int b, int m) {
  if (b == 0) return 1LL;
  int ret = bigMod(a, b / 2, m);
  ret = (ret * 1LL * ret) % m;
  if (b & 1) ret = (ret * 1LL * a) % m;
  return ret;
}
struct fwht {
  int P1[MAX], P2[MAX];
  int MOD, INV;
  fwht() {}
  fwht(int _MOD) {
    MOD = _MOD;
    INV = bigMod(2, MOD - 2, MOD);
  }
  void walsh_transform(int* ar, int n) {
    if (n == 0) return;
    int i, m = n / 2;
    walsh_transform(ar, m);
    walsh_transform(ar + m, m);
    for (i = 0; i < m; i++) {
      int x = ar[i], y = ar[i + m];
      ar[i] = (x + y >= MOD ? x + y - MOD : x + y),
      ar[i + m] = (x - y + MOD >= MOD ? x - y + MOD - MOD : x - y + MOD);
    }
  }
  void inverse_walsh_transform(int* ar, int n) {
    if (n == 0) return;
    int i, m = n / 2;
    inverse_walsh_transform(ar, m);
    inverse_walsh_transform(ar + m, m);
    for (i = 0; i < m; i++) {
      int x = ar[i], y = ar[i + m];
      ar[i] = ((x + y >= MOD ? x + y - MOD : x + y) * 1LL * INV) % MOD;
      ar[i + m] =
          ((x - y + MOD >= MOD ? x - y + MOD - MOD : x - y + MOD) * 1LL * INV) %
          MOD;
    }
  }
  vector<int> convolution(int n, int* A, int* B) {
    for (int i = 0; i < n; i++) P1[i] = A[i];
    for (int i = 0; i < n; i++) P2[i] = B[i];
    walsh_transform(P1, n);
    walsh_transform(P2, n);
    for (int i = 0; i < n; i++) P1[i] = (P1[i] * 1LL * P2[i]) % MOD;
    inverse_walsh_transform(P1, n);
    return vector<int>(P1, P1 + n);
  }
};
struct edges {
  int u, v, w;
} ara[MAX];
vector<int> ed[MAX], isBridge[MAX];
bool vis[MAX];
int st[MAX], low[MAX], Time = 0;
int cnum;
int comp[MAX];
void findBridge(int s, int par) {
  int i, x, ch = 0, j;
  vis[s] = 1;
  Time++;
  st[s] = low[s] = Time;
  for (i = 0; i < ed[s].size(); i++) {
    x = ed[s][i];
    if (!vis[x]) {
      ch++;
      findBridge(x, s);
      low[s] = min(low[s], low[x]);
      if (low[x] > st[s]) {
        isBridge[s][i] = 1;
        j = lower_bound(ed[x].begin(), ed[x].end(), s) - ed[x].begin();
        isBridge[x][j] = 1;
      }
    } else if (par != x)
      low[s] = min(low[s], st[x]);
  }
}
int szComp[MAX];
void dfs(int s) {
  int i, x;
  vis[s] = 1;
  comp[s] = cnum;
  szComp[cnum]++;
  for (i = 0; i < ed[s].size(); i++) {
    if (!isBridge[s][i]) {
      x = ed[s][i];
      if (!vis[x]) dfs(x);
    }
  }
}
int cnt[44][MAX];
vector<int> C;
int RM[MAX];
void processBridge(int n, int m) {
  memset(vis, 0, sizeof(vis));
  Time = 0;
  for (int i = 1; i <= n; i++)
    if (!vis[i]) findBridge(i, -1);
  cnum = 0;
  memset(vis, 0, sizeof(vis));
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      cnum++;
      dfs(i);
    }
  }
  for (int i = 1; i <= cnum; i++) {
    if (szComp[i] > 1) {
      RM[i] = C.size();
      C.push_back(i);
    }
  }
  for (int i = 1; i <= m; i++) {
    if (comp[ara[i].u] == comp[ara[i].v]) {
      cnt[RM[comp[ara[i].u]]][ara[i].w]++;
    }
  }
}
int tmp[MAX];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  fwht T1 = fwht(1e9 + 7);
  fwht T2 = fwht(1e9 + 9);
  int n, m, u, v, w;
  cin >> n >> m;
  int tot = 0;
  for (int i = 1; i <= m; i++) {
    cin >> u >> v >> w;
    ed[u].push_back(v);
    ed[v].push_back(u);
    isBridge[u].push_back(0);
    isBridge[v].push_back(0);
    ara[i].u = u;
    ara[i].v = v;
    ara[i].w = w;
    tot ^= w;
  }
  for (int i = 1; i <= n; i++) sort(ed[i].begin(), ed[i].end());
  processBridge(n, m);
  if (C.size() == 0) {
    cout << tot << endl;
  } else if (C.size() == 1) {
    int mn = 1 << (B + 1);
    int ways = 0;
    for (int i = 0; i < (1 << B); i++) {
      if (cnt[0][i]) {
        if (mn > (tot ^ i)) {
          mn = tot ^ i;
          ways = cnt[0][i];
        }
      }
    }
    cout << mn << " " << ways << endl;
  } else {
    vector<int> V1 = T1.convolution(1 << B, cnt[0], cnt[1]);
    vector<int> V2 = T2.convolution(1 << B, cnt[0], cnt[1]);
    for (int i = 2; i < C.size(); i++) {
      for (int j = 0; j < (1 << B); j++) tmp[j] = V1[j];
      V1 = T1.convolution(1 << B, tmp, cnt[i]);
      for (int j = 0; j < (1 << B); j++) tmp[j] = V2[j];
      V2 = T2.convolution(1 << B, tmp, cnt[i]);
    }
    int mn = 1 << (B + 1);
    int ways = 0;
    for (int i = 0; i < (1 << B); i++) {
      if (V1[i] or V2[i]) {
        if (mn > (tot ^ i)) {
          mn = tot ^ i;
          ways = V1[i];
        }
      }
    }
    cout << mn << " " << ways << endl;
  }
  return 0;
}