#include <bits/stdc++.h>
using namespace std;
int MOD = 1e9 + 7;
int MOD2 = 998244353;
int INF = 1e18;
const int L = 17;
const int N = (1 << L);
vector<int> gr[N];
vector<int> gr2[N];
int kol_c = 0;
int comp[N];
int h[N];
int used[N];
int dfs(int v, int pr) {
  h[v] = h[pr] + 1;
  int an = MOD;
  for (auto i : gr[v]) {
    if (!h[i]) {
      an = min(an, dfs(i, v));
    } else {
      if (i != pr) an = min(an, h[i]);
    }
  }
  comp[v] = (an >= h[v]);
  return an;
}
void cm(int v, int kol) {
  if (comp[v])
    comp[v] = ++kol_c;
  else
    comp[v] = kol;
  used[v] = 1;
  for (auto i : gr[v]) {
    if (!used[i]) {
      cm(i, comp[v]);
    }
  }
}
vector<int> num[N];
vector<int> cnt, cnt2;
vector<int> cnt_, cnt2_;
int binpow(int x, int y) {
  if (!y) return 1;
  if (y % 2) return (1ll * (long long)x * (long long)binpow(x, y - 1)) % MOD;
  return binpow((1ll * (long long)x * (long long)x) % MOD, y / 2);
}
int revers(int x) { return binpow(x % MOD, MOD - 2); }
void adamar(vector<int> &a, int l, int r) {
  if (l + 1 >= r) return;
  int mid = (r + l) / 2;
  adamar(a, l, mid);
  adamar(a, mid, r);
  for (int i = l; i < mid; i++) {
    int u = a[i], v = a[i + mid - l];
    a[i] = (u + v) % MOD;
    a[i + mid - l] = (u - v) % MOD;
  }
}
void andamar(vector<int> &a, int l, int r) {
  if (l + 1 >= r) return;
  int mid = (r + l) / 2;
  andamar(a, l, mid);
  andamar(a, mid, r);
  for (int i = l; i < mid; i++) a[i] = (a[i] + a[i + mid - l]) % MOD;
}
void revandamar(vector<int> &a, int l, int r) {
  if (l + 1 >= r) return;
  int mid = (r + l) / 2;
  revandamar(a, l, mid);
  revandamar(a, mid, r);
  for (int i = l; i < mid; i++) a[i] = (a[i] - a[i + mid - l]) % MOD;
}
void ordamar(vector<int> &a, int l, int r) {
  if (l + 1 >= r) return;
  int mid = (r + l) / 2;
  ordamar(a, l, mid);
  ordamar(a, mid, r);
  for (int i = l; i < mid; i++) a[i + mid - l] = (a[i] + a[i + mid - l]) % MOD;
}
void revordamar(vector<int> &a, int l, int r) {
  if (l + 1 >= r) return;
  int mid = (r + l) / 2;
  revordamar(a, l, mid);
  revordamar(a, mid, r);
  for (int i = l; i < mid; i++) a[i + mid - l] = (-a[i] + a[i + mid - l]) % MOD;
}
vector<int> xormult(vector<int> a, vector<int> b) {
  adamar(a, 0, a.size());
  adamar(b, 0, b.size());
  for (int i = 0; i < a.size(); i++)
    a[i] = (1ll * (long long)a[i] * (long long)b[i]) % MOD;
  adamar(a, 0, a.size());
  int revn = revers(a.size());
  for (int i = 0; i < a.size(); i++)
    a[i] = (1ll * (long long)a[i] * (long long)revn) % MOD;
  return a;
}
int binpow2(int x, int y) {
  if (!y) return 1;
  if (y % 2) return (1ll * (long long)x * (long long)binpow2(x, y - 1)) % MOD2;
  return binpow2((1ll * (long long)x * (long long)x) % MOD2, y / 2);
}
int revers2(int x) { return binpow2(x % MOD2, MOD2 - 2); }
void adamar2(vector<int> &a, int l, int r) {
  if (l + 1 >= r) return;
  int mid = (r + l) / 2;
  adamar2(a, l, mid);
  adamar2(a, mid, r);
  for (int i = l; i < mid; i++) {
    int u = a[i], v = a[i + mid - l];
    a[i] = (u + v) % MOD2;
    a[i + mid - l] = (u - v) % MOD2;
  }
}
void andamar2(vector<int> &a, int l, int r) {
  if (l + 1 >= r) return;
  int mid = (r + l) / 2;
  andamar2(a, l, mid);
  andamar2(a, mid, r);
  for (int i = l; i < mid; i++) a[i] = (a[i] + a[i + mid - l]) % MOD2;
}
void revandamar2(vector<int> &a, int l, int r) {
  if (l + 1 >= r) return;
  int mid = (r + l) / 2;
  revandamar2(a, l, mid);
  revandamar2(a, mid, r);
  for (int i = l; i < mid; i++) a[i] = (a[i] - a[i + mid - l]) % MOD2;
}
void ordamar2(vector<int> &a, int l, int r) {
  if (l + 1 >= r) return;
  int mid = (r + l) / 2;
  ordamar2(a, l, mid);
  ordamar2(a, mid, r);
  for (int i = l; i < mid; i++) a[i + mid - l] = (a[i] + a[i + mid - l]) % MOD2;
}
void revordamar2(vector<int> &a, int l, int r) {
  if (l + 1 >= r) return;
  int mid = (r + l) / 2;
  revordamar2(a, l, mid);
  revordamar2(a, mid, r);
  for (int i = l; i < mid; i++)
    a[i + mid - l] = (-a[i] + a[i + mid - l]) % MOD2;
}
vector<int> xormult2(vector<int> a, vector<int> b) {
  adamar2(a, 0, a.size());
  adamar2(b, 0, b.size());
  for (int i = 0; i < a.size(); i++)
    a[i] = (1ll * (long long)a[i] * (long long)b[i]) % MOD2;
  adamar2(a, 0, a.size());
  int revn = revers2(a.size());
  for (int i = 0; i < a.size(); i++)
    a[i] = (1ll * (long long)a[i] * (long long)revn) % MOD2;
  return a;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0),
      cout << fixed << setprecision(20);
  int n, m;
  cin >> n >> m;
  int x = 0;
  for (int i = 0; i < m; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    x ^= w;
    u--, v--;
    gr[u].push_back(v);
    gr2[u].push_back(w);
    gr[v].push_back(u);
    gr2[v].push_back(w);
  }
  dfs(0, 0);
  cm(0, 0);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < gr[i].size(); j++) {
      int to = gr[i][j];
      int w = gr2[i][j];
      if (i > to && comp[i] == comp[to]) {
        num[comp[i]].push_back(w);
      }
    }
  }
  cnt.assign(N, 0);
  cnt_.assign(N, 0);
  cnt[x] = 1;
  cnt_[x] = 1;
  for (int ii = 0; ii < N; ii++) {
    if (num[ii].size()) {
      cnt2.assign(N, 0);
      cnt2_.assign(N, 0);
      for (auto j : num[ii]) {
        cnt2[j]++;
        cnt2_[j]++;
      }
      cnt = xormult(cnt, cnt2);
      cnt_ = xormult2(cnt_, cnt2_);
      for (int i = 0; i < N; i++) {
        cnt[i] %= MOD;
        cnt_[i] %= MOD2;
        if (cnt[i] < 0) {
          cnt[i] += MOD;
        }
        if (cnt_[i] < 0) {
          cnt_[i] += MOD2;
        }
      }
    }
  }
  for (int i = 0; i < N; i++) {
    if (cnt[i] || cnt_[i]) {
      cout << i << " " << cnt[i];
      break;
    }
  }
}
