Under construction

Still being built. Things may change

Stock

Interview

Time limit1sMemory limit512 MB

Summary
Find the shortest subarray whose sum minus y times its length is at least Z and whose length times y is at most X, breaking ties by the latest start.
Level

Medium6 of 10

Topics
Sliding window, Prefix sum, Binary search, Array
Solved
No attempts yet

Problem

You want to buy and sell stock to make a profit. The laws on stock investment changed recently, introducing the following restrictions.

  • The market is open only for n days, from day 1 to day n.
  • You may take part only during some consecutive k days (k ≥ 1). On each day you take part, you must buy stock every day.
  • The price at which you buy stock is y won per day, always constant.
  • The price at which you sell stock is V[i] won when you bought on day i, and it depends on the day you bought. V[i] may be negative.
  • You start with an initial capital of X won.
  • You cannot sell the stock you bought until day n, the last day the market is open, has passed.
  • You must make a profit of at least Z won. (Z ≥ 0)

That is, if you bought stock from day i to day j with 1 ≤ i ≤ j ≤ n, then

(V[i] + V[i+1] + … + V[j-1] + V[j]) - y × (j - i + 1) ≥ Z and y × (j - i + 1) ≤ X must hold.

Your goal is to find, among all purchase plans that yield a profit of at least Z won, the one with the shortest period.

In other words, as long as you can make at least Z won, the exact profit does not matter, and you want the period over which you make at least Z won to be as short as possible. Write a program that outputs the start day and end day i, j of such a period.

If several shortest purchase plans exist, output the one with the largest i (that is, the one that enters the market latest).

If no way exists to make a profit of at least Z won, output -1.

Input

The first line gives the number of test cases T (1 ≤ T ≤ 10).

Each test case is given over two lines.

The first line gives n, X, y, Z separated by spaces. They satisfy 0 ≤ X, y, Z ≤ 10⁹.

The second line gives n integers V separated by spaces. Each V[i] satisfies |V[i]| ≤ 10⁶.

Output

For each test case, output the answer on one line. If no i, j satisfy the conditions stated in the problem, output -1. Otherwise, output the i, j that minimizes (j - i + 1) and, among those, maximizes i, separated by a space.

Examples1

  1. Example 1

    Input
    5
    1 0 0 1
    1
    2 0 0 4
    1 2
    3 0 0 3
    2 -1 2
    3 0 0 2
    2 -1 2
    3 0 0 1
    2 -1 2
    
    Expected output
    1 1
    -1
    1 3
    3 3
    3 3