#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
vector<int> e[100010], ei[100010];
int bad[100050], w[100050], d[100050], in[100050], st[100050], stn, ste[100050];
vector<vector<int> > be;
int dfs(int v, int p = -1) {
  d[v] = 1;
  in[v] = 1;
  st[stn++] = v;
  for (int i = 0; i < e[v].size(); i++) {
    int w = e[v][i], wi = ei[v][i];
    if (w == p || bad[wi]) continue;
    if (!d[w]) {
      ste[stn] = wi;
      if (dfs(w, v)) return 1;
    } else if (in[w]) {
      bad[wi] = 1;
      vector<int> ba(1, wi);
      --stn;
      do {
        ba.push_back(ste[stn--]);
      } while (st[stn] != w);
      be.push_back(ba);
      return 1;
    }
  }
  --stn;
  in[v] = 0;
  return 0;
}
int a[1 << 17], b[1 << 17], af[1 << 17], bf[1 << 17];
void tr(int *f, int inv = 0) {
  for (int i = 0; i < 17; i++) {
    for (int j = 0; j < 1 << 17; j++) {
      if (j >> i & 1) continue;
      int p = j, q = j ^ (1 << i);
      int pv = f[p], qv = f[q];
      f[p] = pv + qv;
      f[q] = pv + mod - qv;
      if (f[p] >= mod) f[p] -= mod;
      while (f[q] >= mod) f[q] -= mod;
      if (inv) {
        f[p] = f[p] * 500000004ll % mod;
        f[q] = f[q] * 500000004ll % mod;
      }
    }
  }
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d%d%d", &u, &v, &w[i]);
    --u;
    --v;
    e[u].push_back(v);
    e[v].push_back(u);
    ei[u].push_back(i);
    ei[v].push_back(i);
  }
  while (dfs(0)) {
    for (int i = 0; i < n; i++) {
      d[i] = 0;
      in[i] = 0;
    }
    stn = 0;
  }
  int wa = 0;
  for (int i = 0; i < m; i++) {
    wa ^= w[i];
  }
  a[wa] = af[wa] = 1;
  tr(a);
  tr(af);
  for (int i = 0; i < be.size(); i++) {
    for (int j = 0; j < 1 << 17; j++) {
      b[j] = 0;
    }
    for (int j = 0; j < be[i].size(); j++) {
      b[w[be[i][j]]]++;
    }
    for (int j = 0; j < 1 << 17; j++) {
      bf[j] = !!b[j];
    }
    tr(b);
    tr(bf);
    for (int j = 0; j < 1 << 17; j++) {
      a[j] = (long long)a[j] * b[j] % mod;
      af[j] = (long long)af[j] * bf[j] % mod;
    }
  }
  tr(a, 1);
  tr(af, 1);
  for (int i = 0; i < 1 << 17; i++) {
    if (af[i]) {
      printf("%d %d\n", i, a[i]);
      break;
    }
  }
  return 0;
}
