Sum Source Detection

공개된 정수 O와 목표 합 X가 주어질 때, X를 만드는 모든 유효한 부분집합 합에 반드시 포함되는 공개 보유자의 번호를 구한다.

어려움9동적 계획법조합론그리디아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

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,,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,,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.

입력

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

$N$ $M$ $K$ $Q$ $O_{1}$ $\cdots$ $O_{N}$ $X_{1}$ $\cdots$ $X_{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 (1N,0M,N+M40)(1 \le N, 0 \le M, N + M \le 40). KK is an integer (1K200,000)(1 \le K \le 200{,}000). QQ is the number of rounds of the game (1Q10,000)(1 \le Q \le 10{,}000).

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

The third line indicates QQ integers X_1,,X_QX\_{1}, \cdots, X\_{Q} (0X_iK)(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,,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 1jM1 \le j \le M. Note that O_1=min_1kNO_kO\_{1} = \min\_{1 \le k \le N} O\_{k} holds.
  • _j=1NO_j+_k=1MS_k=K\sum\_{j=1}^{N} O\_{j} + \sum\_{k=1}^{M} S\_{k} = K.
  • There is at least one pair of subsets U1,,NU \subseteq \\{1, \dots, N\\} and V1,,MV \subseteq \\{1, \dots, M\\} such that _jUO_j+_kVS_k=X_i\sum\_{j \in U} O\_{j} + \sum\_{k \in V} S\_{k} = X\_{i} holds.

출력

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.