VK often holds hackathons where programmers solve various problems. VK is now preparing a new hackathon in which anyone can try their hand at developing a unique and useful application or service for one of several tracks including Fintech, Culture, Media, and others.
As with any well-organized hackathon, to allow participants to fully dedicate themselves to solving the task at hand they are provided with a carefully organized venue. Pleasant bonuses often include food and drinks, which can be enjoyed over the several days that participants spend at the venue.
This time VK is organizing a new hackathon, and $$$m$$$ participants have gathered at the venue. For these $$$m$$$ participants the organizers have ordered $$$n$$$ pizzas which are arranged in a row and numbered from $$$1$$$ to $$$n$$$. It is known that:
Periodically, participants get up from their places and approach the row of pizzas to take a slice. Participant number $$$i$$$ approaches the pizza numbered $$$s_i$$$ at time $$$t_i$$$, after which they immediately find the slice of pizza with the least dough thickness among pizzas from $$$1$$$ to $$$s_i$$$ and start moving towards it. It takes each participant the same amount of time to move between two adjacent pizzas — exactly $$$v$$$ seconds. Several participants can be near the same pizza at the same time.
As soon as a participant reaches the pizza they have chosen, they take the slice and return to their seat. If several participants have chosen the same slice and reach it simultaneously, the participant with the lower number takes the slice. If the slice a participant was counting on is taken by someone else, that participant immediately chooses a new target using the same algorithm: they look at all the pizzas from the first to their current position, select the minimum among them, and start moving towards it.
Formally, this process can be described as follows. At every whole number of seconds $$$t$$$:
Based on the information about participants' approaches to the pizzas, determine for each participant the thickness of the pizza slice they received and how much time they spent in the row.
The first line of input contains three space-separated integers $$$n$$$, $$$m$$$, and $$$v$$$ — the number of pizzas, the number of participants and the time it takes each participant to move between adjacent pizzas ($$$1 \le n, m \le 10^5$$$; $$$1 \le v \le 10^9$$$).
The second line lists $$$n$$$ space-separated integers $$$a_i$$$ — the thickness of the first slice of each pizza ($$$0 \le a_i \le 10^9$$$).
In the $$$i$$$-th of the following $$$m$$$ lines, two integers $$$s_i$$$ and $$$t_i$$$ are given, separated by a space — the starting position and the time of the participant's approach to the row of pizzas ($$$1 \le s_i \le n$$$; $$$0 \le t_i \le 10^9$$$).
Output $$$m$$$ lines, in the $$$i$$$-th of which print a pair of space-separated integers: the dough thickness of the pizza slice received by the $$$i$$$-th participant and the time it took the participant to reach it.
Points for each subtask are awarded only if all tests of that subtask and the required subtasks are successfully passed.
| Subtask | Points | Constraints | Required subtasks |
| 0 | – | examples | |
| 1 | 8 | $$$\max(t_i) \le 10^4$$$; $$$n, m, v \le 100$$$ | 0 |
| 2 | 10 | all $$$s_i$$$ are equal and all $$$t_i$$$ are equal | |
| 3 | 13 | $$$|a_i - a_j| \ge m$$$ for any $$$i \ne j$$$ | |
| 4 | 19 | $$$n, m \le 1000$$$ | 0, 1 |
| 5 | 16 | $$$m \le 1000$$$ | 0, 1, 4 |
| 6 | 34 | none | 0 – 5 |
5 3 11 2 3 4 55 13 22 4
2 3 1 2 2 1
7 7 31 5 3 2 5 4 15 42 34 21 67 83 22 4
2 3 1 3 5 6 2 0 1 0 4 6 3 3
In the first example, events will occur in the following order:
| Name |
|---|


