#ABC257B. [ABC257B] 1D Pawn

[ABC257B] 1D Pawn

Score : 200200 points

Problem Statement

There are NN squares, indexed Square 11, Square 22, …, Square NN, arranged in a row from left to right. Also, there are KK pieces. The ii-th piece from the left is initially placed on Square AiA_i. Now, we will perform QQ operations against them. The ii-th operation is as follows:

  • If the LiL_i-th piece from the left is on its rightmost square, do nothing.
  • Otherwise, move the LiL_i-th piece from the left one square right if there is no piece on the next square on the right; if there is, do nothing.

Print the index of the square on which the ii-th piece from the left is after the QQ operations have ended, for each i=1,2,,Ki=1,2,\ldots,K.

Constraints

  • 1KN2001\leq K\leq N\leq 200
  • $1\leq A_1
  • 1Q10001\leq Q\leq 1000
  • 1LiK1\leq L_i\leq K
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN KK QQ

A1A_1 A2A_2 \ldots AKA_K

L1L_1 L2L_2 \ldots LQL_Q

Output

Print KK integers in one line, with spaces in between. The ii-th of them should be the index of the square on which the ii-th piece from the left is after the QQ operations have ended.

5 3 5
1 3 4
3 3 1 1 2
2 4 5

At first, the pieces are on Squares 11, 33, and 44. The operations are performed against them as follows:

  • The 33-rd piece from the left is on Square 44. This is not the rightmost square, and the next square on the right does not contain a piece, so move the 33-rd piece from the left to Square 55. Now, the pieces are on Squares 11, 33, and 55.
  • The 33-rd piece from the left is on Square 55. This is the rightmost square, so do nothing. The pieces are still on Squares 11, 33, and 55.
  • The 11-st piece from the left is on Square 11. This is not the rightmost square, and the next square on the right does not contain a piece, so move the 11-st piece from the left to Square 22. Now, the pieces are on Squares 22, 33, and 55.
  • The 11-st piece from the left is on Square 22. This is not the rightmost square, but the next square on the right (Square 33) contains a piece, so do nothing. The pieces are still on Squares 22, 33, and 55.
  • The 22-nd piece from the left is on Square 33. This is not the rightmost square, and the next square on the right does not contain a piece, so move the 22-nd piece from the left to Square 44; Now, the pieces are still on Squares 22, 44, and 55.

Thus, after the QQ operations have ended, the pieces are on Squares 22, 44, and 55, so 22, 44, and 55 should be printed in this order, with spaces in between.

2 2 2
1 2
1 2
1 2
10 6 9
1 3 5 7 8 9
1 2 3 4 5 6 5 6 2
2 5 6 7 9 10