Score : $600$ points
Given is a permutation $P=(P_1,P_2,\ldots,P_N)$ of $1,2,\ldots,N$, and an integer $X$.
Additionally, $Q$ queries are given. The $i$-th query is represented as a triple of numbers $(C_i,L_i,R_i)$. Each query does the following operation on the permutation $P$.
In the final permutation $P$ after executing all queries in the given order, find $i$ such that $P_i=X$.
Input is given from Standard Input in the following format:
$N$ $Q$ $X$ $P_1$ $P_2$ $\ldots$ $P_N$ $C_1$ $L_1$ $R_1$ $C_2$ $L_2$ $R_2$ $\vdots$ $C_Q$ $L_Q$ $R_Q$
Print the answer.
5 2 1 1 4 5 2 3 1 3 5 2 1 3
3
Initially, the permutation is $P=[1,4,5,2,3]$. The queries change it as follows.
In the final permutation, we have $P_3=1$, so $3$ should be printed.
7 3 3 7 5 3 1 2 4 6 1 1 7 2 3 6 2 5 7
7
The final permutation is $P=[1,2,6,5,7,4,3]$.