#Lutece1147. 秋实大哥带我飞

秋实大哥带我飞

Migrated from Lutece 1147 秋实大哥带我飞

All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.

Description

Qiushidage Bring Me Fly

然而题目和题面并没有什么关系。

给出nn个点,mm条带权无向边,问你从11号点到nn号点的最短路中有多少种走法?

Input

第一行两个数nn,mm分别表示点的个数和边的个数。 (2n20002\leq n\leq 20001m20001\leq m\leq2000

接下来mm行,每行3个数uu,vv,ww表示uu号点到vv号点有一条距离为ww的边。(1u,vn1\leq u,v\leq n0w1000000\leq w\leq 100000

数据保证11号点能够到达nn号点,点和边都可以被走多次。

Output

如果有无穷种走法,输出-1。否则输出走法的方案数mod 1000000009

Samples

4 4
1 2 1
1 3 1
2 4 1
3 4 1
2
4 4
1 2 1
1 3 1
2 4 1
3 4 0
-1

Resources

2015 UESTC Training for Graph Theory