You are given an array of integers $$$a$$$ of size $$$n$$$ and a permutation $$$p$$$ of size $$$n$$$. There are $$$q$$$ queries of three types coming to you:
Please, process all queries and print answers to queries of type $$$1$$$.
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the size of the array and permutation.
The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$-10^8 \le a_i \le 10^8$$$).
The third line contains $$$n$$$ distinct integers $$$p_1, p_2, \ldots, p_n$$$ ($$$1 \le p_i \le n$$$).
The fourth line contains a single integer $$$q$$$ — the number of queries ($$$1 \le q \le 2 \cdot 10^5$$$).
Next $$$q$$$ lines contain description of queries. The $$$i$$$-th of them starts with an integer $$$t_i$$$ ($$$1 \le t_i \le 3$$$) — the query type.
For every first type query, print a single integer — the answer to this query.
5 6 9 -5 3 0 2 3 1 5 4 6 1 1 5 2 1 1 1 1 5 3 1 5 2 1 -1 1 1 5
13 16 11
8 -15 52 -4 3 5 9 0 5 2 4 6 8 1 3 5 7 10 2 2 2 2 5 -1 1 1 8 1 1 5 1 5 8 3 1 6 2 1 50 1 1 8 2 6 -20 1 1 8
61 45 22 461 301
1 1 1 1 1 1 1
1
In the first example:
There are $$$6$$$ queries.
Name |
---|