High Score#11445

High Score

1 second
128 megabytes
Hard

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 line has two integers n\:(1 \le n \le 2500) and m\:(1 \le m \le 5000): the number of rooms and tunnels. The rooms are numbered 1, 2, \dots , n.

Then, there are lines describing the tunnels. Each line has three integers , b\:(1 \le a, b \le n) and x\:(−10^9 \le x \le 10^9): 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 .

Examples

Example 1

Loading
Loading