The King of Akabeko has two princes. The king decided to divide the country into two when he abdicated, and let each prince rule the country one by one. The names of the new countries are Aka and Beko. There are N towns and M roads connecting the two towns in Akabeko. The King decided to allocate the town of Akabeko and some roads to the two countries by following the steps below.

(1) Select two towns and allocate them to Aka and Beko, respectively.
(2) Select the town s that has already been allocated. In addition, select an unallocated town t that is connected by a single road from the town s. Then, the road between towns s and t and town t are distributed to the countries to which towns s are allocated.
(3) Repeat (2) until it cannot be done.

In fact, the two princes are not very close to each other, so the king wants to make the distance between the two countries as large as possible. Here, the distance between the two countries is the shortest length of the road connecting the towns of Aka and Beko.

Given the town and road information of Akabeko, create a program to find the maximum distance between Akabe and Beko after distribution and how many distributions will result in such a distance. However, the two allocation results are distinguished when different towns or roads are allocated to Aka and Beko.



input

The input is given in the following format.


N M
s1 t1 d1
s2 t2 d2
::
sM tM dM


The first line consists of two integers. N (2 ≤ N ≤ 100) represents the number of towns and M (N-1 ≤ M ≤ N (N-1) / 2) represents the number of roads. The next M line is given a way to connect the two towns. si and ti (1 ≤ si ≠ ti ≤ N) represent the numbers of the two towns where the i-th road connects. di (1 ≤ di ≤ 109) represents the length of the i-th path.

The input satisfies the following conditions.

* Both towns can be reached by using several roads.
* There are no more than two roads between any two towns.
* There are no more than 5 roads of the same length.

output

The maximum value of the distance between Aka and Beko after distribution and the number of combinations are output on one line separated by blanks. However, since the number of combinations after distribution can be very large, the remainder divided by 1,000,000,007 is output instead.

Example

Input

6 7
1 2 1
2 3 2
3 1 3
4 5 4
5 6 5
6 4 6
1 4 7


Output

7 18
#include<unordered_map>
#include<utility>
template<typename T>
class UnionFind {
public:
  void unite(const T& a, const T& b) {
    T x = find(a), y = find(b);
    if(size_[x] < size_[y]) std::swap(x, y);
    if(x != y) parent_[y] = x, size_[x] += size_[y];
  }
  const T find(const T& x) {
    if(!parent_.count(x)) {
      size_[x] = 1;
      return parent_[x] = x;
    }
    return (parent_[x] == x) ? x : (parent_[x] = find(parent_[x]));
  }
  const int size(const T& x) {
    return size_[find(x)];
  }
private:
  std::unordered_map<T, T> parent_;
  std::unordered_map<T, int> size_;
};

#include<bits/stdc++.h>
using namespace std;

using Weight = long long int;
using Vertex = int;
struct Edge {Vertex from, to; Weight weight;};
using Row = valarray<Weight>;
using Matrix = valarray<Row>;

const Weight MOD = 1e9 + 7;
int N, M;
vector<Vertex> root;
vector<Edge> E;

Weight power(Weight m, Weight n) {
  if(!n) return 1;
  if(n & 1) return (power(m, n - 1) * m) % MOD;
  return power((m * m) % MOD, n >> 1);
}

Weight determinant(Matrix A) {
  const int N = A.size() - 1;
  Weight det = 1;
  for(int i = 0; i < N; ++i) {
    for(int k = i; k < N; ++k) if(A[k][i] != 0) {
      if((k - i) & 1) det = -det + MOD;
      swap(A[i], A[k]);
      break;
    }
    if(A[i][i] == 0) return 0;
    det = (det * A[i][i]) % MOD;
    for(int k = i + 1; k < N; ++k) {
      auto c = (A[k][i] * power(A[i][i], MOD - 2)) % MOD;
      c = -c + MOD;
      for(int j = 0; j < N; ++j) A[k][j] = (A[k][j] + c * A[i][j] + MOD) % MOD;
    }
  }
  return det % MOD;
}

Matrix Laplacian(UnionFind<Vertex> cc, Vertex c) {
  Matrix L(Row(Weight(0), cc.size(c) - 1), cc.size(c) - 1);
  vector<Vertex> V;
  for(Vertex v = 0; v < N; ++v) if(cc.find(v) == cc.find(c)) V.push_back(v);
  vector<int> index(N, -1);
  for(int i = 0; i < V.size(); ++i) index[V[i]] = i;
  for(auto e: E) if(cc.find(e.from) == cc.find(c) && cc.find(e.to) == cc.find(c)) {
    L[index[e.from]][index[e.to]] = L[index[e.to]][index[e.from]] = -1 + MOD;
    ++L[index[e.from]][index[e.from]];
    ++L[index[e.to]][index[e.to]];
  }
  return L;
}

Weight spaninng_trees(UnionFind<Vertex> cc, vector<Vertex> root, int bit) {
  auto COUNTRY = {N, N + 1};
  for(int i = 0; i < root.size(); ++i) {
    if((bit >> i) & 1) cc.unite(root[i], N + 1);
    else               cc.unite(root[i], N);
  }
  vector<Weight> det;
  for(auto c: COUNTRY) det.push_back(determinant(Laplacian(cc, c)));
  return (det[0] * det[1]) % MOD;
}

Weight Kruskal() {
  sort(begin(E), end(E), [](Edge lhs, Edge rhs) {return lhs.weight < rhs.weight;});
  UnionFind<Vertex> group;
  for(auto e: E) {
    group.unite(e.from, e.to);
    if(group.size(e.from) == N) return e.weight;
  }
  exit(1);
}

void solve() {
  auto D = Kruskal();

  UnionFind<Vertex> cc;
  for(auto e: E) if(e.weight < D) cc.unite(e.from, e.to);

  set<Vertex> tmp;
  for(Vertex v = 0; v < N; ++v) tmp.insert(cc.find(v));
  vector<Vertex> root(begin(tmp), end(tmp));

  Weight res = 0;
  for(int bit = 1; bit < (1 << root.size()) - 1; ++bit) {
    res = (res + spaninng_trees(cc, root, bit)) % MOD;
  }
  cout << D << " " << res << endl;
}

int main() {
  cin >> N >> M;
  for(int i = 0; i < M; ++i) {
    Vertex s, t; Weight d;
    cin >> s >> t >> d;
    --s; --t;
    E.push_back({s, t, d});
  }
  solve();
}