#P2185. 公路通行税

公路通行税

Description

In the country of PALMIA, there are NN cities connected by roads (each road connects exactly two cities bidirectionally). From any city, it is possible to reach every other city by traveling along one or more roads. Starting this year, a highway toll will be charged. In the middle of each road, there is a tax collector who collects 1 PALMIA COIN (1 PC) from every car that uses this road.

Government officials decided to reduce the number of tax collectors by introducing a road stamp. If a car wants to enter a road, it must stick this stamp on its window.

The officials set the annual road stamp value to be equal to the total cost of making 100100 trips between the two farthest cities. The distance between two cities is defined as the minimum number of roads that must be traversed to get from one city to the other.

Your task is to write a program to compute the value of the road stamp.

Input Format

The input contains multiple test cases. The first line of each test case contains two integers NN and MM (separated by a space), where NN is the number of cities and MM is the number of roads (1N10001 \le N \le 1000, 1M250001 \le M \le 25000). Cities are labeled with integers from 11 to NN. Each of the next MM lines contains a pair of integers AA, BB (1A,BN1 \le A, B \le N), separated by a space, indicating that there is a road between city AA and city BB. The input terminates with a line containing two zeros separated by a space.

Output Format

For each test case, output one line containing the value of the road stamp.

4 4
1 2
2 3
4 2
3 4
0 0
200

Hint

Translated by ChatGPT 5