Construction Project 2
문제
There are stations in JOI Kingdom, numbered from to . There are train lines in JOI Kingdom, numbered from to . The train line (1 ≤ i ≤ M) connects station and station bi-directionally, and requires minutes for travel.
You, a minister of JOI Kingdom, decided to construct a new train line as follows.
- You choose integers and , which satisfy 1 ≤ u < v ≤ N. You construct a new train line, which connects station and station bi-directionally, and requires minutes for travel. Note that you can choose integers such that there already be a train line connecting station and station .
After you construct a new train line, the King of JOI Kingdom becomes happy if he can move from station to station within minutes by using some train lines. Note that transit times and waiting times for train lines are not considered.
There are ways when you choose integers and , and you want to know how many of these ways make the King happy.
Write a program which, given information of stations, the train lines, and the King’s request, calculates number of ways to choose integers that make the King happy.
입력
Read the following data from the standard input.
출력
Write one line to the standard output. The output should contain number of ways to choose integers that make the King happy.
예제
예제 1
7 8 6 7 1 2 1 2 1 1 6 1 2 3 1 2 4 1 3 5 1 3 7 1 4 5 1 5 6 1
4
예제 2
3 2 1 3 1 2 1 2 1 2 3 1
3
예제 3
6 4 2 5 1000000000 1 1 2 1000000000 2 3 1000000000 2 4 1000000000 5 6 1000000000
0
예제 4
18 21 4 8 678730772 3000000062 5 13 805281073 8 17 80983648 3 8 996533440 10 16 514277428 2 5 57914340 6 11 966149890 8 12 532734310 2 9 188599710 2 3 966306014 12 16 656457780 16 18 662633078 1 15 698078877 2 8 665665772 2 6 652261981 14 15 712798281 7 13 571169114 13 14 860543313 6 7 454251187 9 14 293590683 6 14 959532841 3 11 591245645
16