#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 42;
const int V = 1 << 17;
const long long mod7 = 1000000007;
vector<pair<int, int>> g[N];
int used[N];
long long powi(long long a, long long b, long long m) {
  long long c = 1;
  while (b) {
    if (b & 1) c = (c * a) % m;
    a = (a * a) % m;
    b >>= 1;
  }
  return c;
}
void fwht(vector<long long>& a, bool mod = true) {
  for (int j = 1; j < a.size(); j <<= 1) {
    for (int i = 0; i < a.size(); i++) {
      if (i & j) {
        int u = a[i - j];
        int v = a[i];
        a[i - j] = u + v;
        a[i] = u - v;
        if (a[i - j] >= mod7 && mod) a[i - j] -= mod7;
        if (a[i] < 0 && mod) a[i] += mod7;
      }
    }
  }
}
int par[N];
int www[N];
vector<vector<int>> cycles;
void dfs(int v, int p = -1, int ww = 0) {
  www[v] = ww;
  used[v] = true;
  par[v] = p;
  for (pair<int, int> e : g[v]) {
    int to = e.first;
    int w = e.second;
    if (to == p) continue;
    if (!used[to]) {
      dfs(to, v, w);
    } else {
      if (used[to] == 2) continue;
      int ptr = v;
      vector<int> cycle = {w};
      while (ptr != to) {
        used[ptr] = 2;
        cycle.push_back(www[ptr]);
        ptr = par[ptr];
      }
      used[ptr] = 2;
      cycles.emplace_back(move(cycle));
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  int allxor = 0;
  for (int i = 0; i < m; i++) {
    int a, b, w;
    cin >> a >> b >> w;
    a--;
    b--;
    g[a].push_back({b, w});
    g[b].push_back({a, w});
    allxor ^= w;
  }
  dfs(0);
  vector<long long> v(V);
  vector<long long> vv(V);
  v[allxor] = 1;
  vv[allxor] = 1;
  fwht(v);
  fwht(vv, false);
  for (auto cycle : cycles) {
    vector<long long> u(V);
    vector<long long> uu(V);
    for (int c : cycle) u[c]++;
    for (int c : cycle) uu[c] = 1;
    fwht(u);
    fwht(uu, false);
    for (int i = 0; i < V; i++) v[i] = v[i] * u[i] % mod7;
    for (int i = 0; i < V; i++) vv[i] = vv[i] * uu[i];
    fwht(vv, false);
    for (int i = 0; i < V; i++) vv[i] = !!vv[i];
    fwht(vv, false);
  }
  fwht(v);
  fwht(vv, false);
  long long inv = powi(V, mod7 - 2, mod7);
  for (int i = 0; i < V; i++) v[i] = v[i] * inv % mod7;
  for (int i = 0; i < V; i++) {
    if (vv[i]) {
      cout << i << " " << v[i] << endl;
      break;
    }
  }
  return 0;
}
