For the daily milking, Farmer John's $N$ cows ($1 \le N \le 50000$) always line up in the same order. One day Farmer John decides to organize a game of Ultimate Frisbee with some of the cows. To keep things simple, he takes a contiguous range of cows from the lineup to play. However, for all the cows to have fun, their heights should not differ too much.
Farmer John prepares $Q$ candidate groups ($1 \le Q \le 180000$) along with the cows' heights ($1 \le \text{height} \le 1000000$). For each group, determine the difference in height between the shortest and the tallest cow in that group.
Note: on the largest test case, I/O takes up the majority of the runtime.