- Time limit: 1.00 s
- Memory limit: 512 MB
You play a game consisting of rooms and tunnels. Your initial score is , and each tunnel increases your score by where may be both positive or negative. You may go through a tunnel several times.
Your task is to walk from room to room . What is the maximum score you can get?
Input
The first input line has two integers and : the number of rooms and tunnels. The rooms are numbered .
Then, there are lines describing the tunnels. Each line has three integers , and : the tunnel starts at room , ends at room , and it increases your score by . All tunnels are one-way tunnels.
You can assume that it is possible to get from room to room .
Output
Print one integer: the maximum score you can get. However, if you can get an arbitrarily large score, print .
Constraints
Example
Input:
4 5 1 2 3 2 4 -1 1 3 -2 3 4 7 1 4 4
Output:
5