- Time limit: 1.00 s
- Memory limit: 512 MB
Uolevi is working at a holiday resort in a tropical archipelago. His job is to guide incoming cruise ships through the shallow waters. The archipelago consists of islands numbered and the keel depth limit for a path between islands and is . As Uolevi gets constantly peppered with questions like "can we get from island to island with our ship?", he decides to write a program that calculates the maximum keel depth for of the most popular routes numbered . The -th route goes from island to island .
Input
The first line contains two integers and . The -th of next lines contains integers . The -th of next lines contains two integers and .
Output
Print the maximum keel depth for the -th route on the -th line.
Constraints
- if
Example
Input:
5 5 0 13 10 67 42 13 0 40 40 32 10 40 0 94 69 67 40 94 0 53 42 32 69 53 0 1 3 1 4 1 5 4 5 5 2
Output:
67 67 67 69 40