CSES - E4590 2017 Homework 1 - Internet connection
  • Time limit: 1.00 s
  • Memory limit: 128 MB

The internet connection between Teemu and Taina has had problems lately. Before more investigation on the subject, Teemu decided to find out the theoretical maximum rate at which he can send data to Taina.

Can you help Teemu to calculate the maximum speed?

Input

The first line of the input has two integers nn and mm: the number of computers and number of connections in the network. Computers are numbered 1,2,,n1,2,\ldots,n. Computer numbered 11 is owned by Teemu and computer nn is owned by Taina.

After the first line mm lines follow, each of which describe one connection between computers. The line has three integers aa, bb and cc. This means that computer aa can send data to computer bb at a rate of cc bytes/s.

Output

Your program should print one integer: the maximum rate (bytes/s) at which Teemu can send data to Taina.

Limits

  • 2n1002 \le n \le 100
  • 1m10001 \le m \le 1000
  • 1a,bn1 \le a, b \le n
  • 1c1091 \le c \le 10^9

Example

Input:

4 5
1 2 2
1 3 5
2 4 3
3 2 2
3 4 1

Output:

4