there undirecte weight connected graph you give positive integer n denote graph n node label 1 n array edge edgesi ui vi weighti denote edge node ui vi weight equal weightiA path node start node end sequence node z0 z1 z2 zk z0 start zk end edge zi zi1 0 k1the distance path sum weight edge path let distancetolastnodex denote short distance path node n node x a restricted path path satisfie distanceToLastNodezi distancetolastnodezi1 0 k1return number restrict path node 1 node n since number large return modulo 109 7 Example 1input n 5 edge 1231332311425223515410output 3explanation each circle contain node number black distancetolastnode value blue the restrict path are1 1 2 52 1 2 3 53 1 3 5example 2input n 7 edge 131412734253561672753264output 1explanation each circle contain node number black distancetolastnode value blue the restricted path 1 3 7 constraints1 n 2 104n 1 edgeslength 4 104edgesilength 31 ui vi nui vi1 weighti 105There edge nodesThere path node