Calvin is driving his favorite vehicle on the 101 freeway. He notices that the check engine light of his vehicle is on, and he wants to service it immediately to avoid any risks. Luckily, a service lane runs parallel to the highway. The service lane varies in width along its length.
You will be given an array of widths at points along the road (indexes), then a list of the indexes of entry and exit points. Considering each entry and exit point pair, calculate the maximum size vehicle that can travel that segment of the service lane safely.
Complete the code stub below to return an array of integers representing the values calculated.
The first line of input contains two integers, and , where denotes the number of width measurements you will receive and the number of test cases. The next line has space-separated integers which represent the array .
The next lines contain two integers, and , where is the start index and is the end index of the segment being considered.
For each test case, print the number that represents the largest vehicle type that can pass through the entire segment of the service lane between indexes and inclusive.