import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; import java.util.Map.Entry; import java.util.Scanner; public class Main { public static final long INF = Long.MAX_VALUE / 2 - 1; public static void main(String[] args) { Scanner sc = new Scanner(System.in); final int N = sc.nextInt(); final int M = sc.nextInt(); ArrayList> fwd_adj = new ArrayList>(); ArrayList> rev_adj = new ArrayList>(); for(int i = 0; i < N; i++){ fwd_adj.add(new HashMap()); rev_adj.add(new HashMap()); } int[] in_degs = new int[N]; int[] out_degs = new int[N]; for(int i = 0; i < M; i++){ final int A = sc.nextInt(); final int B = sc.nextInt(); final long C = sc.nextLong(); fwd_adj.get(A).put(B, C); rev_adj.get(B).put(A, C); in_degs[B]++; out_degs[A]++; } long[] max_path = new long[N]; long[] rev_max_path = new long[N]; Arrays.fill(max_path, -1); Arrays.fill(rev_max_path, -1); max_path[0] = 0; LinkedList queue = new LinkedList<>(); for(int i = 0; i < N; i++){ if(in_degs[i] != 0){ continue; } queue.add(i); } while(!queue.isEmpty()){ final int node = queue.poll(); for(final Entry entry : fwd_adj.get(node).entrySet()){ final int next = entry.getKey(); final long cost = max_path[node] + entry.getValue(); if(max_path[next] < 0 || max_path[next] < cost){ max_path[next] = cost; } in_degs[next]--; if(in_degs[next] == 0){ queue.add(next); } } } rev_max_path[N - 1] = max_path[N - 1]; for(int i = 0; i < N; i++){ if(out_degs[i] != 0){ continue; } queue.add(i); } while(!queue.isEmpty()){ final int node = queue.poll(); for(final Entry entry : rev_adj.get(node).entrySet()){ final int prev = entry.getKey(); final long cost = rev_max_path[node] - entry.getValue(); if(rev_max_path[prev] < 0 || rev_max_path[prev] > cost){ rev_max_path[prev] = cost; } out_degs[prev]--; if(out_degs[prev] == 0){ queue.add(prev); } } } int count = 0; for(int i = 0; i < N; i++){ if(max_path[i] != rev_max_path[i]){ count++; } } System.out.println(max_path[N-1] + " " + count + "/" + N); //System.out.println(Arrays.toString(max_path)); //System.out.println(Arrays.toString(rev_max_path)); } }