LearnPy Hub
← Arena
AdvancedRating 1700

Number of Shortest Routes

Roads are one-way with positive lengths. Print the length of the shortest route from 1 to n and how many different shortest routes there are (modulo 1 000 000 007). If n can't be reached, print -1 0.

Input

n and m; then m lines 'u v w'.

Output

Two integers.

Sample 1

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

Sample 2

Input
2 0
Output
-1 0
solution.py
Output appears here
Number of Shortest Routes · Python Arena problem · LearnPy Hub