In a small town, there's a ritual where each day, every resident takes a series of steps, either to the right or left, over N days. Starting at the town center, each day, they move according to the guidance of a mystical scroll: a list of values, X which determines their direction. On the ith day, a positive X[i] sends them to the right by X[i] steps, a negative X[i] sends them to the left by X[i] steps, and a zero means they stay where they are. Over time, the townsfolk became curious about their wanderings.
They posed M queries, each asking: on which days did residents find themselves at least W steps away from the town center, both for the first time and the last time? If residents are never at least W steps away from the town center, the answer is −1.
Input format
Output format
For each test case, answer all the M queries. For each query, print two days on which residents are at least a W steps away from the town center, the first and last time in a new line. If residents are never at least W steps away from the town center, print −1 in a new line.
Constraints
1≤T≤1051≤N≤106−1012≤X[i]≤1012 ∀ i∈[1,N]1≤M≤1061≤W≤1018The sum of all values of N over all test cases doesn't exceed 106The sum of all values of M over all test cases doesn't exceed 106
The first line denotes T = 1.
For test case 1:
So,
Now,