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:
- 1 k c – If \(c\) is +, then \(A_k\) increases by \(1\). If \(c\) is -, then \(A_k\) decreases by \(1\). (\(1\leq k\leq N\); \(c\) is + or -)
- 2 k c – If \(c\) is +, then \(B_k\) increases by \(1\). If \(c\) is -, then \(B_k\) decreases by \(1\). (\(1\leq k\leq N\); \(c\) is + or -)
- 3 k – Pak Chanek wants to know the value of \(\text{RankOverall}(k)\) at that moment. (\(1\leq k\leq N\))
Output
For each event of type \(3\), output a line containing an integer representing the value of \(\text{RankOverall}(k)\) at that moment.
Note
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:
- \(\text{RankA}(1)=1\), \(\text{RankB}(1)=3\)
- \(\text{RankA}(2)=3\), \(\text{RankB}(2)=1\)
- \(\text{RankA}(3)=5\), \(\text{RankB}(3)=4\)
- \(\text{RankA}(4)=1\), \(\text{RankB}(4)=2\)
- \(\text{RankA}(5)=3\), \(\text{RankB}(5)=4\)
So it can be obtained that \(\text{RankOverall}(1)=2\).
Примеры
| № | Входные данные | Выходные данные |
|
1
|
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
|