#P1619H. Permutation and Queries
Permutation and Queries
No submission language available for this problem.
Description
You are given a permutation of elements. A permutation of elements is an array of length containing each integer from to exactly once. For example, and are permutations, but and are not permutations. You should perform queries.
There are two types of queries:
- — swap and .
- — print the number that will become if we assign times.
The first line contains two integers and ().
The second line contains integers .
Each of the next lines contains three integers. The first integer is () — type of query. If , then the next two integers are and (; ) — first-type query. If , then the next two integers are and () — second-type query.
It is guaranteed that there is at least one second-type query.
For every second-type query, print one integer in a new line — answer to this query.
Input
The first line contains two integers and ().
The second line contains integers .
Each of the next lines contains three integers. The first integer is () — type of query. If , then the next two integers are and (; ) — first-type query. If , then the next two integers are and () — second-type query.
It is guaranteed that there is at least one second-type query.
Output
For every second-type query, print one integer in a new line — answer to this query.
Samples
Note
In the first example .
The first query is to print . The answer is .
The second query is to print . The answer is .
The third query is to swap and . Now .
The fourth query is to print . The answer is .