#jag2017summerday3j. [jag2017summer_day3_j]Sum Source Detection

[jag2017summer_day3_j]Sum Source Detection

MathJax.Hub.Config({ tex2jax: { inlineMath: [["","",""], ["\\(","\\)"]], processEscapes: true }}); blockquote { font-family: Menlo, Monaco, "Courier New", monospace; color: #333333; display: block; padding: 8.5px; margin: 0 0 9px; font-size: 16px; line-height: 18px; background-color: #f5f5f5; border: 1px solid #ccc; border: 1px solid rgba(0, 0, 0, 0.15); -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; white-space: pre; white-space: pre-wrap; word-break: break-all; word-wrap: break-word; }

Problem Statement

JAG members began a game with integers. The game consists of N+M+1N + M + 1 players: NN open number holders, MM secret number holders, and one answerer, you.

In the preparation, an integer KK is told to all N+M+1N+M+1 players. N+MN + M number holders choose their own integers per person under the following restrictions:

  • Each holder owns a positive integer.
  • The sum of all the integers equals KK.
  • Every integer owned by secret number holders is strictly less than any integers owned by open number holders.

After the choices, NN open number holders show their integers O_1,dots,O_NO\_{1}, \\dots, O\_{N} to the answerer while secret number holders do not.

The game has QQ rounds. At the beginning of each round, MM secret number holders can change their numbers under the above restrictions, while open number holders cannot. Then N+MN + M number holders select part of members among them arbitrary, calculate the sum XX of the integers owned by the selected members, and tell XX to the answerer. For each round, the answerer tries to identify the definitely selected open number holders from the information KK, XX, and O_1,dots,O_NO\_{1}, \\dots, O\_{N}: The answerer will get points per actually selected open number holder in the answer. On the other hand, if the answer contains at least one non-selected member, you lose your points got in the round. Thus, the answerer, you, must answer only the open number holders such that the holders are definitely selected.

Your task in this problem is to write a program to determine all the open number holders whose integers are necessary to the sum for each round in order to maximize your points.


Input

The input consists of a single test case formatted as follows.

NN MM KK QQ O_1O\_{1} cdots\\cdots O_NO\_{N} X_1X\_{1} cdots\\cdots X_QX\_{Q}

The first line consists of four integers NN, MM, KK, and QQ. NN and MM are the numbers of open number holders and secret number holders respectively (1leN,0leM,N+Mle40)(1 \\le N, 0 \\le M, N + M \\le 40). KK is an integer (1leKle200,000)(1 \\le K \\le 200{,}000). QQ is the number of rounds of the game (1leQle10,000)(1 \\le Q \\le 10{,}000).

The second line contains NN integers O_1,cdots,O_NO\_{1}, \\cdots, O\_{N}, as the ii-th open number holder owns O_iO\_{i} (1leO_1ledotsleO_NleK1 \\le O\_{1} \\le \\dots \\le O\_{N} \\le K).

The third line indicates QQ integers X_1,cdots,X_QX\_{1}, \\cdots, X\_{Q} (0leX_ileK)(0 \\le X\_{i} \\le K). X_iX\_{i} is the sum of the integers owned by the selected members in the ii-th round.

It is guaranteed that there is at least one way to compose X_iX\_{i}. In other words, you can assume that there is at least one integer sequence S_1,dots,S_MS\_{1}, \\dots, S\_{M}, which represents integers owned by secret number holders, satisfying the followings:

  • 0<S_j<O_10 < S\_{j} < O\_{1} for 1lejleM1 \\le j \\le M. Note that O_1=min_1lekleNO_kO\_{1} = \\min\_{1 \\le k \\le N} O\_{k} holds.
  • $\\sum\_{j=1}^{N} O\_{j} + \\sum\_{k=1}^{M} S\_{k} = K$.
  • There is at least one pair of subsets Usubseteq1,dots,NU \\subseteq \\{1, \\dots, N\\} and Vsubseteq1,dots,MV \\subseteq \\{1, \\dots, M\\} such that $\\sum\_{j \\in U} O\_{j} + \\sum\_{k \\in V} S\_{k} = X\_{i}$ holds.

Output

On each sum X_iX\_{i}, print the indices of the open number holders whose integers are required to make up X_iX\_{i}. The output for each sum has to be printed in one line, in ascending order, and separated by a single space. If there is no open number holder whose integer is certainly used for X_iX\_{i}, print 1-1 in one line.


Sample Input 1

2 2 23 2
7 10
9 10

Output for Sample Input 1

1
-1

The first sum 99 can be achieved only by the first open number holder's 77 plus 22 of a secret number holder. In this case, secret number holders have 22 and 44. The second open number holder's 1010 is a candidate for the second sum 1010. The first open holder's 77 plus 33 is also possible one, as secret number holders have two 33s.


Sample Input 2

1 1 100 3
51
49 51 100

Output for Sample Input 2

-1
1
1

The only secret number holder owns 4949. The output for the first sum is 1-1 because the open number holder's 5151 is not selected.


Sample Input 3

2 1 58152 4
575 57500
575 57577 77 0

Output for Sample Input 3

1
2
-1
-1

In this case, the only secret number holder definitely has 7777. The output for the last sum 00 is 1-1 because no integer of open number holders is needed to form 00.


Sample Input 4

3 2 1500 1
99 300 1000
99

Output for Sample Input 4

1

The only way to compose 9999 is to select the first open number holder only; secret number holders have two integers between 11 and 9898, while the sum of them must be 101101.


Sample Input 5

3 2 20 19
3 3 11
1 2 3 4 5 6 7 8 9 11 12 13 14 15 16 17 18 19 20

Output for Sample Input 5

-1
-1
-1
-1
-1
-1
1 2
1 2
1 2
3
3
3
3
3
3
3
1 2 3
1 2 3
1 2 3

The numbers owned by the two secret number holders are 11 and 22. At least one open number holder's 33 is required to compose 55 and 66 respectively, but it is impossible to determine the definitely selected open number holder(s). On the other hand, 77 needs the two open number holders who both own 33.