You play a game consisting of n rooms and m tunnels. Your initial score is 0, and each tunnel increases your score by x where x may be both positive or negative. You may go through a tunnel several times.
Your task is to walk from room 1 to room n. What is the maximum score you can get?
The first line has two integers n(1≤n≤2500) and m(1≤m≤5000): the number of rooms and tunnels. The rooms are numbered 1,2,…,n.
Then, there are m lines describing the tunnels. Each line has three integers a, b(1≤a,b≤n) and x(−109≤x≤109): the tunnel starts at room a, ends at room b, and it increases your score by x. All tunnels are one-way tunnels.
You can assume that it is possible to get from room 1 to room n.
Print one integer: the maximum score you can get. However, if you can get an arbitrarily large score, print −1.