#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
const int N = 1 << 17;
int timer = 0;
vector<int> vis, par;
vector<vector<int>> g;
vector<vector<long long>> fre, c;
vector<pair<pair<int, int>, int>> e;
template <typename T>
void fhwt(vector<T> &a, bool inv) {
  int n = a.size();
  for (int len = 1; len < n; len <<= 1) {
    for (int i = 0; i < n; i += 2 * len) {
      for (int j = 0; j < len; ++j) {
        T u = a[i + j], v = a[i + j + len];
        if (!inv) {
          a[i + j] = (u + v) % M;
          a[i + j + len] = (u - v + M) % M;
        } else {
          a[i + j] = (u + v) % M;
          a[i + j + len] = (u - v + M) % M;
          if (a[i + j] & 1) a[i + j] += M;
          if (a[i + j + len] & 1) a[i + j + len] += M;
          a[i + j] /= 2;
          a[i + j + len] /= 2;
        }
      }
    }
  }
}
void dfs(int x, int p) {
  vis[x] = ++timer;
  par[x] = p;
  for (auto u : g[x]) {
    if (u == p) continue;
    int v = e[u].first.second, w = e[u].second;
    if (!vis[v])
      dfs(v, u ^ 1);
    else if (vis[x] > vis[v]) {
      c.emplace_back();
      fre.emplace_back();
      c.back().resize(N, 0);
      fre.back().resize(N, 0);
      c.back()[w]++;
      fre.back()[w] = 1;
      int r = x;
      while (r != v) {
        int rw = e[par[r]].second;
        c.back()[rw]++;
        fre.back()[rw] = 1;
        r = e[par[r]].first.second;
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  int n, m, xr = 0;
  cin >> n >> m;
  g.resize(n);
  par.resize(n, 0);
  vis.resize(n, 0);
  for (int i = 0; i < m; ++i) {
    int u, v, w;
    cin >> u >> v >> w;
    --u;
    --v;
    g[u].push_back(e.size());
    g[v].push_back(e.size() + 1);
    e.push_back({{u, v}, w});
    e.push_back({{v, u}, w});
    xr ^= w;
  }
  c.emplace_back();
  fre.emplace_back();
  c.back().resize(N, 1);
  fre.back().resize(N, 1);
  dfs(0, -1);
  for (int i = 1; i < (int)c.size(); ++i) {
    fhwt(c[i], 0);
    fhwt(fre[i], 0);
    for (int j = 0; j < (int)c[i].size(); ++j) {
      c[0][j] = c[0][j] * c[i][j] % M;
      fre[0][j] = fre[0][j] * fre[i][j] % M;
    }
  }
  fhwt(c[0], 1);
  fhwt(fre[0], 1);
  int ans = INT_MAX, ways = 0;
  for (int i = 0; i < N; ++i) {
    if (fre[0][i] && (xr ^ i) < ans) {
      ans = xr ^ i;
      ways = c[0][i];
    }
  }
  cout << ans << " " << ways << '\n';
}
