Maximum Mean Cycle

No attempts yetTime limit1sMemory limit128 MB

Problem

You are given a directed graph with weighted edges. Find a cycle whose average edge weight is as large as possible. The average edge weight of a cycle is defined as (the sum of the weights of its edges) divided by (the number of its edges).

Input

The first line contains two integers nn and mm (2n1002 \le n \le 100, 2m1042 \le m \le 10^4), the number of vertices and the number of edges. Each of the next mm lines contains three integers aa, bb, cc (1a,bn1 \le a, b \le n, aba \ne b, 0c1060 \le c \le 10^6), describing a directed edge from vertex aa to vertex bb with weight cc. Between any pair of vertices there is at most one edge in each direction.

Output

Print the maximum average edge weight over all cycles as a reduced fraction p/qp/q in lowest terms (gcd(p,q)=1\gcd(p, q) = 1, q1q \ge 1). If the value is an integer vv, print it as v/1v/1. It is guaranteed that the graph always contains at least one cycle.