Time limit
2s
Memory limit
512 MB
All roads lead to Rome.
A journey of a thousand ri begins with one step.
In World Country, every road is one-way, and there is no way to follow roads and return to the city where you started. In other words, the road network is a directed acyclic graph.
There are two special cities, One Step and Rome. From One Step, every city can be reached, and from every city there is a route to Rome. There are enough people to assign one person to every distinct route from One Step to Rome. They all start at the same time and run without resting. Each road has a fixed travel time.
How long does it take until every person reaches Rome?
Among the routes that take the longest time, every road used by at least one of those routes will be marked. Find how many roads must be marked.
The first line contains the number of cities n (1≤n≤10000). The second line contains the number of roads m (1≤m≤100000).
Each of the next m lines contains three integers u, v, and w, describing a one-way road from city u to city v that takes w time to traverse. Every road satisfies 1≤u,v≤n and 1≤w≤10000.
The last line contains the city numbers of One Step and Rome, in that order.
On the first line, print the time when every person has reached Rome.
On the second line, print the number of roads that belong to at least one longest route and therefore must be marked.