Preparando MOJI
After the success of the basketball teams formed and trained by Pak Chanek last year (Basketball Together), Pak Chanek wants to measure the performance of each player that is considered as a superstar.
There are $$$N$$$ superstar players that have been trained by Pak Chanek. At the end of the season, some calculations will be made on the performance of the $$$N$$$ players using an international method. Each player has two values $$$A_i$$$ and $$$B_i$$$ where each represents the offensive and defensive value of that player.
Define $$$\text{RankA}(i)$$$ as the offensive ranking of the $$$i$$$-th player, whose value is $$$c+1$$$ with $$$c$$$ here representing the number of $$$j$$$ ($$$1 \leq j \leq N$$$) such that $$$A_j>A_i$$$. Define $$$\text{RankB}(i)$$$ as the defensive ranking of the $$$i$$$-th player, whose value is $$$c+1$$$ with $$$c$$$ here representing the number of $$$j$$$ ($$$1 \leq j \leq N$$$) such that $$$B_j>B_i$$$.
Define $$$\text{RankOverall}(i)$$$ as the overall ranking of the $$$i$$$-th player, whose value is $$$c+1$$$ with $$$c$$$ here representing the number of $$$j$$$ ($$$1 \leq j \leq N$$$) such that $$$\text{RankA}(j)+\text{RankB}(j)<\text{RankA}(i)+\text{RankB}(i)$$$.
During the next $$$Q$$$ days, exactly one event will happen on each day. Each event is one of the three following possibilities:
The first line contains a single integer $$$N$$$ ($$$1\leq N\leq10^5$$$) — the number of superstar players.
The second line contains $$$N$$$ integers $$$A_1, A_2, A_3 \ldots, A_N$$$ ($$$1 \leq A_i \leq 10^5$$$) — the offensive value of each player.
The third line contains $$$N$$$ integers $$$B_1, B_2, B_3 \ldots, B_N$$$ ($$$1 \leq B_i \leq 10^5$$$) — the defensive value of each player.
The fourth line contains a single integer $$$Q$$$ ($$$1\leq Q\leq10^5$$$) — the number of events.
The $$$j$$$-th of the next $$$Q$$$ lines contains the $$$j$$$-th event as described. At any moment, each value of $$$A_i$$$ and $$$B_i$$$ is always between $$$1$$$ and $$$10^5$$$ inclusive. There is at least one event of type $$$3$$$.
For each event of type $$$3$$$, output a line containing an integer representing the value of $$$\text{RankOverall}(k)$$$ at that moment.
5 3 3 1 3 2 3 7 1 3 1 8 3 1 3 2 2 4 + 1 2 - 3 2 3 3 2 2 - 3 1
2 1 2 5 2
At the $$$8$$$-th event, $$$A=[3,2,1,3,2]$$$ and $$$B=[3,6,1,4,1]$$$. It can be obtained that the values of $$$\text{RankA}$$$ and $$$\text{RankB}$$$ for each player are as follows:
So it can be obtained that $$$\text{RankOverall}(1)=2$$$.