#SGM0000022. Xóa phần tử khỏi danh sách (List Removals)

Xóa phần tử khỏi danh sách (List Removals)

List Removals

Source: CSES

Version: Phuoc Hung OJ Extended

Problem Statement

You are given a list of nn integers. During the process, if the current list has kk elements, they are numbered from 11 to kk in their current order.

There are exactly nn removals. At removal ii, remove the element currently at position pip_i and print its value.

Input

The first line contains nn.

The second line contains x1,x2,…,xnx_1,x_2,\ldots,x_n.

The third line contains p1,p2,…,pnp_1,p_2,\ldots,p_n, where 1≤pi≤n−i+11\le p_i\le n-i+1.

Output

Print the removed values in order.

Subtasks

  • Subtask 1 — 20%: 1≤n≤501\le n\le 50.
  • Subtask 2 — 30%: 1≤n≤50001\le n\le 5000.
  • Subtask 3 — 50%: 1≤n≤2⋅1051\le n\le 2\cdot10^5, 1≤xi≤1091\le x_i\le10^9.

Examples

Input

5
2 6 1 4 2
3 1 3 1 1

Output

1 2 2 6 4

Explanation

The sample is processed in order; every printed item/line corresponds to an operation that requires output.