import sys import graphlib input = sys.stdin.buffer.readline def solve(): N, M = map(int, input().split()) # Python 3.9 の新機能 ts = graphlib.TopologicalSorter() parents, children = [[] for _ in range(N)], [[] for _ in range(N)] for _ in range(M): a, b, c = map(int, input().split()) # to, fromの順なので注意 ts.add(b, a) parents[b].append((a, c)) children[a].append((b, c)) tps = tuple(ts.static_order()) earliest, latest = [0] * N, [0] * N for x in tps: earliest[x] = max((earliest[p] + v for p, v in parents[x]), default=0) for x in reversed(tps): latest[x] = max((latest[c] + v for c, v in children[x]), default=0) T = earliest[N - 1] P = sum(earliest[x] + latest[x] != T for x in range(N)) print(f'{T} {P}/{N}') if __name__ == '__main__': solve()