#ZSEQ. ZSequence
ZSequence
You will be given a sequence A containing N positive integers, a1, a2 ... aN.
Let S(i, j) = ai + ai + 1 + ... + aj, if i <= j.
You should find K - 1 indexes, m1 < m2 < ... < mK - 1 such that lb1 <= S(1, m1) <= ub1 ... lbi <= S(mi - 1 + 1, mi) <= ubi and lbK <= S(mK - 1 + 1, N) <= ubK.
If there are multiple solution, print the first lexicographically.
Input
The first line of the standard input contains two space-separated integers N (2 <= N <= 5 000) and K (1 <= K - 1 <= N - 1). Next N lines contain integers a1, a2 ... aN, respectively, 1 <= ai <= 105.
i-th of the next K lines contain integers lbi and ubi, 1 <= lbi <= ubi <= 109.
Output
On the first line of the standard output you should print space-separated K - 1 indices of the solution as already explained. If such solution does not exist, you should print only one integer -1.
Example
Input: 4 3 1 2 3 4 1 3 2 4 3 10</p>Output: 1 2
Input: 4 3 1 2 3 4 1 3 2 4 3 4 Output: 2 3
Input: 4 3 1 2 3 4 1 3 2 4 3 3 Output: -1