#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7, inv2 = (mod + 1) / 2, mod2 = 1e9 + 9,
          inv22 = (mod2 + 1) / 2;
vector<pair<int, int> > e[111111];
int isused[111111];
int fa[111111], fae[111111];
pair<int, int> operator+(const pair<int, int> &a, const pair<int, int> &b) {
  return {(a.first + b.first) % mod, (a.second + b.second) % mod2};
}
pair<int, int> operator-(const pair<int, int> &a, const pair<int, int> &b) {
  return {(a.first - b.first + mod) % mod, (a.second - b.second + mod2) % mod2};
}
void fwt(pair<int, int> *P, int opt) {
  for (int i = 2; i <= (1 << 17); i <<= 1)
    for (int p = i >> 1, j = 0; j < 1 << 17; j += i)
      for (int k = j; k < j + p; ++k) {
        pair<int, int> x = P[k], y = P[k + p];
        P[k] = (x + y);
        P[k + p] = x - y;
        if (opt == -1)
          P[k].first = 1ll * P[k].first * inv2 % mod,
          P[k + p].first = 1ll * P[k + p].first * inv2 % mod,
          P[k].second = 1ll * P[k].second * inv22 % mod2,
          P[k + p].second = 1ll * P[k + p].second * inv22 % mod2;
      }
}
pair<int, int> xx[1 << 17], kk[1 << 17];
void dfs(int now, int p) {
  isused[now] = 1, fa[now] = p;
  for (pair<int, int> k : e[now])
    if (k.first != p) {
      if (!isused[k.first])
        fae[k.first] = k.second, dfs(k.first, now);
      else if (isused[k.first] == 1) {
        memset(xx, 0, sizeof(xx));
        xx[k.second].first++, xx[k.second].second++;
        int tmp = now;
        while (tmp != k.first)
          xx[fae[tmp]].first++, xx[fae[tmp]].second++, tmp = fa[tmp];
        fwt(xx, 1);
        for (int i = 0; i < 1 << 17; i++)
          kk[i].first = kk[i].first * 1ll * xx[i].first % mod,
          kk[i].second = kk[i].second * 1ll * xx[i].second % mod2;
      }
    }
  isused[now] = 2;
}
int main() {
  kk[0].first = kk[0].second = 1;
  fwt(kk, 1);
  int n, m;
  scanf("%d%d", &n, &m);
  int u, v, w, res = 0;
  for (int i = 1; i < m + 1; i++)
    scanf("%d%d%d", &u, &v, &w), e[u].emplace_back(v, w),
        e[v].emplace_back(u, w), res ^= w;
  dfs(1, 1);
  fwt(kk, -1);
  pair<int, int> xx = {1 << 18, 0};
  for (int i = 0; i < 1 << 17; i++)
    if (kk[i].first || kk[i].second) xx = min(xx, {res ^ i, kk[i].first});
  printf("%d %d\n", xx.first, xx.second);
}
