Lineville


Lineville is a city in which nn houses are arranged in a line. To travel from 1 house to an adjacent house, it takes 1 minute. Fortunately, there are mm transport services which take you from one house to another, taking a particular amount of time. These services exist in one direction, but not necessarily the other. What is the shortest time it takes to travel from house 1 to house nn?

Input

The first line contains the integer nn and mm.

The following mm lines contains 3 integers: a,b,ca, b, c. There exists a transport service from house aa to bb which takes cc minutes.

Output

Output the time in minutes to travel from house 11 to house nn.

Constraints

  • 1≤a,b≤n≤100001 \le a, b \le n \le 10000
  • 1≤m≤10001 \le m \le 1000
  • 1≤c≤1091 \le c \le 10^9

Example 1

Input 1
5 5
4 4 1
3 2 2
5 4 2
1 4 1
3 2 2
Output 1
2

Example 2

Input 2
10 10
9 8 2
5 6 5
8 10 4
9 1 4
4 10 1
8 5 2
6 4 5
3 3 2
6 10 5
6 1 5
Output 2
4

Comments0


No comments yet

Be the first to comment.

New comment


Log in to join the discussion.