#include <bits/stdc++.h>
using namespace std;
const int N = 1 << 17, P1 = 1000000007, P2 = 998244353;
using ll = long long;
vector<pair<int, int>> v[N];
vector<vector<int>> p;
int n, m;
int w[N], dfn[N], idx, sum, fv[N];
ll f[N], g[N], ff[N], gg[N];
void dfs(int pos, int fa) {
  dfn[pos] = ++idx;
  for (auto &i : v[pos]) {
    if (i.first == fa) continue;
    if (dfn[i.first] > dfn[pos]) {
      int cur = i.second;
      for (int j = i.first; j != pos; j = fv[j]) cur ^= w[j];
      vector<int> vv{cur ^ i.second};
      for (int j = i.first; j != pos; j = fv[j]) vv.push_back(cur ^ w[j]);
      p.push_back(vv);
      sum ^= cur;
    } else if (!dfn[i.first]) {
      fv[i.first] = pos;
      w[i.first] = i.second;
      dfs(i.first, pos);
    }
  }
}
void FWT_xor(ll a[], int fl, int P) {
  ll inv2 = (P + 1) / 2;
  for (int i = 1; i < N; i <<= 1)
    for (int len = i << 1, j = 0; j < N; j += len)
      for (int k = 0; k < i; k++) {
        ll x = a[j + k], y = a[i + j + k];
        a[j + k] = (x + y) % P;
        a[i + j + k] = (x + P - y) % P;
        if (fl == -1)
          a[j + k] = a[j + k] * inv2 % P,
                a[i + j + k] = a[i + j + k] * inv2 % P;
      }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  int t1, t2, t3;
  for (int i = 1; i <= m; i++) {
    cin >> t1 >> t2 >> t3;
    v[t1].push_back({t2, t3});
    v[t2].push_back({t1, t3});
    sum ^= t3;
  }
  dfs(1, 0);
  f[sum] = g[sum] = 1;
  FWT_xor(f, 1, P1);
  FWT_xor(g, 1, P2);
  for (auto &i : p) {
    memset(ff, 0, sizeof(ff));
    memset(gg, 0, sizeof(gg));
    for (auto &j : i) ++ff[j], ++gg[j];
    FWT_xor(ff, 1, P1);
    FWT_xor(gg, 1, P2);
    for (int j = 0; j < N; j++)
      f[j] = f[j] * ff[j] % P1, g[j] = g[j] * gg[j] % P2;
  }
  FWT_xor(f, -1, P1);
  FWT_xor(g, -1, P2);
  for (int i = 0; i < N; i++)
    if (f[i] || g[i]) {
      cout << i << ' ' << f[i] << endl;
      return 0;
    }
  return 0;
}
