"Title description"
Small A and small b decided to travel by holiday, they will want to go to the city from 1 to n number, and the number of smaller cities in the west of the larger number of cities, it is known that the altitude of each city is different, remember the city i's altitude is hi, city I and City J distance D[i,j] is exactly the absolute value of the difference in altitude of these two cities, namely d[i,j]=| hi−hj|.
During the trip, small A and small b take turns driving, the first day small a drive, after each day rotation. They plan to choose a city as a starting point, keep going east, and travel at most x kilometers. Small A and small B's driving style is different, small b always along the way to choose a recent city as a destination, and small a always follow the direction of the second near the city as the destination (if the current city to two cities in the same distance, it is considered to be closer to the lower elevation of the city). If any one of them is unable to choose the destination city in accordance with their own principles, or if the total distance traveled exceeds x km, they will end the journey.
Before departure, little a wants to know two questions:
(1) for a given x=x0, from which city, small a drive the total number of journeys and small B travel total distance of the smallest ratio (if the travel distance of small B is 0, this time the ratio can be considered infinite, and two infinity as equal). If you are departing from multiple cities, the total number of cars driving in small A is the smallest ratio of the total distance traveled by small B, then the city with the highest altitude is output.
(2) for any given X=xi and departure city Si, small a drive the total number of journeys and small B travel total.
"Input description"
The first line contains an integer n, indicating the number of cities;
The second line has n integers, each two integers separated by a space, in turn, the city 1 to the city of the elevation of N, namely H1, H2, ..., Hn, and each hi is different;
The third line contains an integer X0;
The Forth behavior is an integer m, which represents the given M-group Si and XI;
The next M-line, each line contains 2 integers, Si and Xi, indicating a maximum of Xi kilometres from the city Si.
"Output description"
Output total m+1 line;
The first line contains an integer S0, indicating that for a given X0, from a city numbered S0, small A has the lowest ratio of driving distance to the total distance travelled by small B;
The next M-line, each line contains 2 integers, separated by a space, which in turn represents the total number of miles traveling under a given Si and XI, and the total number of miles traveled by small B.
"Sample Input"
Example 1:
4
2 3 1 4
3
4
1 3
2 3
3 3
4 3
Example 2:
10
4 5 6 1 2 3 7 8 9 10
7
10
1 7
2 7
3 7
4 7
5 7
6 7
7 7
8 7
9 7
10 7
"Sample Output"
Example 1:
1
1 1
2 0
0 0
0 0
Example 2:
2
3 2
2 4
2 1
2 4
5 1
5 1
2 1
2 0
0 0
0 0
"Data range and Tips"
Example 1:
The altitude of each city and the distance between the two cities are shown.
If you start from City 1, you can reach the city is 2, 3, 4, the city and the City 1 distance is 1, 1, 2, but because the city 3 of the altitude is lower than the City 2, so we think the City 3 away from the City 1 nearest, the City 2 from the City 1 second near, so small a will go to the City 2 After reaching the City 2, the front can reach the city is 3, 4, two cities and the City 2 distance is 2, 1, so the city 4 away from the City 2 recently, so small B will walk to the City 4. After arriving in the city 4, there is no city to reach before, so the trip is over.
If you start from City 2, you can reach the city of 3, 4, two cities and the City 2 distance is 2, 1, because the city 3 away from the City 2 second near, so small a will walk to the City 3. After arriving in the city 3, the city that has not yet traveled is 4, so the city is 4 away from the City 3 recently, but if you want to reach the city 4, the total distance is 2+3=5>3, so small B will end the trip directly in the City 3.
If you start from the City 3, you can reach the city of 4, because there is no City 3 second near the city, so the trip has not begun to end.
If you depart from City 4, there is no city to reach, so the journey is over before it begins.
Example 2:
When x=7, if starting from the City 1, then the route is 1-->2-->3-->8-->9, small a walk distance of 1+2=3, small b walk distance of 1+1=2. (In the City 1 o'clock, the nearest city to the small A is 2 and 6, but the City 2 is higher, as the city of 1 second near the city, so small a finally select the City 2; after walking to 9, small a only the city 10 can go, no second choice can be chosen, so there is no choice, to end the trip).
If you depart from City 2, the route is 2-->6-->7, and the distance between small A and small B is 2, 4, respectively.
If you depart from City 3, the route is 3-->8-->9, and the distance between small A and small B is 2, 1, respectively.
If you depart from City 4, the route is 4-->6-->7, and the distance between small A and small B is 2, 4, respectively.
If you depart from City 5, the route is 5-->7-->8, and the distance between small A and small B is 5, 1, respectively.
If you depart from City 6, the route is 6-->8-->9, and the distance between small A and small B is 5, 1, respectively.
If you depart from City 7, the route is 7-->9-->10, and the distance between small A and small B is 2, 1, respectively.
If you depart from City 8, the route is 8-->10, and the distance between small A and small B is 2, 0, respectively.
If you are departing from City 9, the route is 9, and the distance between small A and small B is 0, 0 (the tour ends at the beginning).
If you are departing from City 10, the route is 10, and the distance between small A and small B is 0, 0, respectively.
The total distance traveled from City 2 or City 4 to small A is the smallest of the total distance traveled by small B, but the city's 2 is higher, so the output first behavior is 2.
Data range:
For 30% of the data, there are 1≤n≤20,1≤m≤20;
For 40% of the data, there are 1≤n≤100,1≤m≤100;
For 50% of the data, there are 1≤n≤100,1≤m≤1000;
For 70% of the data, there are 1≤n≤1000,1≤m≤10000;
For 100% of the data, there are 1≤n≤100000,1≤m≤10000,-10^9≤hi≤10^9,0≤x0≤10^9,1≤si≤n,0≤xi≤10^9, the data to ensure that Hi is different.
Travel by car