#include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define mt make_tuple #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)< pii; typedef vector vi; typedef vector vll; vector topologicalSort(const vector > &graph) { int V = (int)graph.size(), cur = 0; vector deg(V), res(V); stack stk; for(int i = 0; i < V; ++i) for(int v : graph[i])deg[v]++; for(int i = 0; i < V; ++i)if(deg[i] == 0)stk.push(i); while(!stk.empty()) { int v = stk.top(); stk.pop(); res[cur++] = v; for(int w : graph[v])if(!--deg[w])stk.push(w); } return cur == V ? res : vector(); } int main(){ ios::sync_with_stdio(false); cin.tie(0); int N, M; cin >> N >> M; vector G(N), W(N), X(N), H(N); rep(i, M) { int u, v, c; cin >> u >> v >> c; G[u].push_back(v); W[u].push_back(c); H[v].push_back(u); X[v].push_back(c); } auto vs = topologicalSort(G); vi dp(N); each(u, vs) { rep(i, sz(G[u])) { int v = G[u][i], c = W[u][i]; smax(dp[v], dp[u] + c); } } queue q; q.push(N - 1); vi vis(N); while(sz(q)) { int u = q.front(); q.pop(); if(vis[u])continue; vis[u] = 1; rep(i, sz(H[u])) { int v, c; v = H[u][i], c = X[u][i]; if(dp[v] + c == dp[u] && !vis[v])q.push(v); } } cout << dp[N - 1] << ' ' << count(all(vis), 0) << '/' << N << endl; }