#ds701. 路径最小值
路径最小值
Path Minimum
Problem Description
Given a tree with vertices, each edge has an edge weight. You are given queries ; for each query, report the minimum edge weight on the path between and .
Input Format
The first line contains two integers .
The next lines each contain two integers , denoting an edge and its weight.
The next lines each contain two integers , the two endpoints of a query.
Output Format
For each query, output one number: the answer.
Sample Input
5 5
1 2 3
2 3 4
2 4 5
3 5 2
4 5
1 3
2 4
1 5
1 4
Sample Output
2
3
5
2
3