SP3978 DISQUERY - Distance Query
Description
[English](/problems/DISQUERY/en/) [Vietnamese](/problems/DISQUERY/vn/)The traffic network in a country consists of N cities (labeled with integers from 1 to N) and N-1 roads connecting the cities. There is a unique path between each pair of different cities, and we know the exact length of each road.
Write a program that will, for each of the K given pairs of cities, find the length of the shortest and the length of the longest road on the path between the two cities.
### Input
The first line of input contains an integer N, 2
The length of each road will be a positive integer less than or equal to 1 000 000.
The next line contains an integer K, 1
### Output
Each of the K lines of output should contain two integers – the lengths from the task description for the corresponding pair of the cities.
Input Format
N/A
Output Format
N/A