After days of reckless spending, Zawaex has found himself in some deep trouble, and is close to going into debt. He currently has dollars left and he finds a list of events that he had predicted would happen to him over the next few days. The th event can be characterized by a single integer , the amount of money in dollars that he would gain from it. (If was negative, he would instead lose money). If Zawaex's amount of money were to become negative after an event, he would instead "borrow" enough money from his friend so that he would end up with dollars after the event. Since Zawaex has a horrible memory, he doesn't know which events have already happened to him. He also doesn't know when he will be able to find employment and get out of this financial crisis. As such, he wants to know how many times he would need to "borrow" money from a friend and how much money he would be left with at the end for different scenarios where a scenario is defined as a contiguous subsequence of the original events. Being uncertain about his future, Zawaex has turned to you for help.
Input Specification
The first line contains three space-separated integers, , , and .
The second line contains space-separated integers, .
lines will follow, each of which contains two space-separated integers, and , denoting the scenario that is the contiguous subsequence between the th and th events.
Output Specification
For each query, output on a new line two space-separated integers, the amount of money that he will be left with in the end and the number of times that Zawaex has to "borrow" money from his friend.
Constraints
In all subtasks,
Subtask 1 [10%]
Subtask 2 [30%]
It is only necessary to determine the amount of money Zawaex will end up with at the end.
For this subtask, your answer will be accepted as long as the first integer in each line is correct. Note that you must still print two integers on each line.
Subtask 3 [60%]
No additional constraints.
Sample Input
5 10 5
4 -7 -8 2 -3
1 5
2 3
1 3
2 4
3 5
Sample Output
0 2
0 1
0 1
2 1
1 0
Explanation for Sample Output
For the first query, he ends up with dollars after the first event, and then needs to "borrow" money after the third event. The dollars he gains from the fourth event is not enough for the dollars he stands to lose from the fifth event, thus he needs to borrow money once again.
For the second subtask only,
0 42384
0 -535
0 3283
2 1232
1 325
would also be considered correct output (only the first integer of each line is output correctly; the second integer on each line were chosen arbitrarily).
Comments