Problem M. Problem M. Walking Plan
时间限制 2500 ms
内存限制 512 MB
There are $n$ intersections in Bytetown, connected with $m$ one way streets. Little Q likes sport walking very much, he plans to walk for $q$ days. On the $i$-th day, Little Q plans to start walking at the $s_i$-th intersection, walk through at least $k_i$ streets and finally return to the $t_i$-th intersection.
Little Q's smart phone will record his walking route. Compared to stay healthy, Little Q cares the statistics more. So he wants to minimize the total walking length of each day. Please write a program to help him find the best route.
输入数据
输出数据
For each walking plan, print a single line containing an integer, denoting the minimum total walking length. If there is no solution, please print -1.
样例输入
复制
2
3 3
1 2 1
2 3 10
3 1 100
3
1 1 1
1 2 1
1 3 1
2 1
1 2 1
1
2 1 1
样例输出
$ Mathjax font initiator $