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;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 100000;
const int MOD = 1000000007;
const int MAXCYC = 42;
const int MAXBITS = 17;
void inc(int &a, int b) {
  if ((a += b) >= MOD) a -= MOD;
}
void dec(int &a, int b) {
  if ((a -= b) < 0) a += MOD;
}
int pw(int x, int n) {
  int ret = 1;
  while (true) {
    if (n & 1) ret = (long long)ret * x % MOD;
    if ((n >>= 1) == 0) return ret;
    x = (long long)x * x % MOD;
  }
}
int n, m;
vector<pair<int, int>> adj[MAXN];
int preidx[MAXN], npre;
int par[MAXN], parlen[MAXN];
vector<int> cyc[MAXCYC];
int ncyc;
void dfs(int at) {
  preidx[at] = npre++;
  for (int i = (0); i < (((int)(adj[at]).size())); ++i) {
    int to = adj[at][i].first, len = adj[at][i].second;
    if (to == par[at]) continue;
    if (preidx[to] != -1) {
      if (preidx[to] < preidx[at]) {
        assert(ncyc < MAXCYC);
        cyc[ncyc].clear();
        cyc[ncyc].push_back(len);
        for (int x = at; x != to; x = par[x]) cyc[ncyc].push_back(parlen[x]);
        ++ncyc;
      }
      continue;
    } else {
      par[to] = at, parlen[to] = len;
      dfs(to);
    }
  }
}
void whtmod(int *a, int nbits) {
  for (int bit = (0); bit < (nbits); ++bit)
    for (int off = 0; off < (1 << nbits); off += 2 << bit)
      for (int i = (0); i < (1 << bit); ++i) {
        int x = a[off + i], y = a[off + (1 << bit) + i];
        a[off + i] = a[off + (1 << bit) + i] = x;
        inc(a[off + i], y);
        dec(a[off + (1 << bit) + i], y);
      }
}
void whtll(long long *a, int nbits) {
  for (int bit = (0); bit < (nbits); ++bit)
    for (int off = 0; off < (1 << nbits); off += 2 << bit)
      for (int i = (0); i < (1 << bit); ++i) {
        long long x = a[off + i], y = a[off + (1 << bit) + i];
        a[off + i] = a[off + (1 << bit) + i] = x;
        a[off + i] += y;
        a[off + (1 << bit) + i] -= y;
      }
}
long long acan[1 << MAXBITS];
int aways[1 << MAXBITS];
long long bcan[1 << MAXBITS];
int bways[1 << MAXBITS];
pair<int, int> solve() {
  npre = 0;
  for (int i = (0); i < (n); ++i) preidx[i] = -1;
  ncyc = 0;
  par[0] = -1, parlen[0] = 0;
  dfs(0);
  int sum = 0;
  for (int at = (0); at < (n); ++at)
    for (int i = (0); i < (((int)(adj[at]).size())); ++i) {
      int to = adj[at][i].first, len = adj[at][i].second;
      if (at < to) sum ^= len;
    }
  memset(acan, 0, sizeof(acan));
  acan[sum] = 1;
  memset(aways, 0, sizeof(aways));
  inc(aways[sum], 1);
  whtmod(aways, MAXBITS);
  for (int i = (0); i < (ncyc); ++i) {
    memset(bcan, 0, sizeof(bcan));
    for (int j = (0); j < (((int)(cyc[i]).size())); ++j) bcan[cyc[i][j]] = 1;
    memset(bways, 0, sizeof(bways));
    for (int j = (0); j < (((int)(cyc[i]).size())); ++j)
      inc(bways[cyc[i][j]], 1);
    whtll(acan, MAXBITS);
    whtll(bcan, MAXBITS);
    for (int k = (0); k < (1 << MAXBITS); ++k) acan[k] *= bcan[k];
    whtll(acan, MAXBITS);
    for (int k = (0); k < (1 << MAXBITS); ++k) acan[k] = acan[k] != 0 ? 1 : 0;
    whtmod(bways, MAXBITS);
    for (int k = (0); k < (1 << MAXBITS); ++k)
      aways[k] = (long long)aways[k] * bways[k] % MOD;
  }
  whtmod(aways, MAXBITS);
  int mlt = pw(1 << MAXBITS, MOD - 2);
  for (int k = (0); k < (1 << MAXBITS); ++k)
    aways[k] = (long long)aways[k] * mlt % MOD;
  for (int k = (0); k < (1 << MAXBITS); ++k)
    if (acan[k]) return make_pair(k, aways[k]);
}
void run() {
  scanf("%d%d", &n, &m);
  for (int i = (0); i < (m); ++i) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    --a, --b;
    adj[a].push_back(make_pair(b, c));
    adj[b].push_back(make_pair(a, c));
  }
  pair<int, int> ans = solve();
  printf("%d %d\n", ans.first, ans.second);
}
int main() {
  run();
  return 0;
}