from collections import deque n,m = map(int,input().split(' ')) e = [[] for i in range(n)] re = [[] for i in range(n)] di = [0] * n for i in range(m): a,b,c = map(int,input().split(' ')) e[a].append((b,c)) re[b].append((a,c)) di[b] += 1 q = deque() for i in range(n): if di[i] == 0: q.append(i) t = [0] * n while len(q): u = q.popleft() for v,c in e[u]: t[v] = max(t[v],t[u] + c) di[v] -= 1 if di[v] == 0: q.append(v) q = deque() q.append(n-1) cp = [False] * n while len(q): u = q.popleft() cp[u] = True for v,c in re[u]: if not cp[v] and t[v] + c == t[u]: q.append(v) print(t[ -1],"%d/%d" % (n-sum(cp),n))