#P10953. 逃不掉的路
逃不掉的路
Problem Description
In modern society, roads are essential.
There are towns and roads. Any two towns are connected by roads, and often by more than one.
However, some roads have been poorly maintained for years and are unpleasant to travel.
In theory, all roads lead to Rome. If one road is bad, you can just take a detour on other roads. But Xiao Lu found that no matter how you travel from town to town , there are always some unavoidable roads that you must pass through.
He wants you to compute: among all paths from to , how many roads are unavoidable?
Input Format
The first line contains and , separated by spaces.
The next lines each contain two integers and , separated by spaces, indicating that there is a bidirectional road of length between towns and .
Line contains .
The next lines each contain two integers and , separated by spaces, representing one query.
Output Format
For each query, output a positive integer indicating how many roads must be passed through when traveling from town to town .
Print one answer per line.
5 5
1 2
1 3
2 4
3 4
4 5
2
1 4
2 5
0
1
Hint
,,
For all testdata, ; for any road, the difference between the indices of its two endpoint towns does not exceed ;
Any two towns are connected by at least one path; the same road will not appear twice; a road’s endpoints will not be the same; the two towns in a query will not be the same.
Translated by ChatGPT 5