题目描述
Problem Description
Takahashi is the organizer of a marathon event and is planning the course for the upcoming marathon. The city where Takahashi lives has 10^6 streets running east-west and 10^6 streets running north-south. The intersection of the x-th street from the west and the y-th street from the south is denoted as (x, y).
To simplify the course, participants are only allowed to move east or north. Takahashi has decided on N checkpoints (p_i, q_i) that can be used for timing participants.
In Takahashi's city, participants prefer to take different routes, so the number of distinct paths is crucial. Due to the need for timing, participants must pass through all checkpoints i where u ≤ i ≤ v when the course is set from checkpoint u to checkpoint v (u < v).
Takahashi needs to answer the following Q queries:
- Change the location of the k_j-th checkpoint to (a_j, b_j).
- Determine which has more distinct paths: from checkpoint l_{1j} to checkpoint r_{1j} or from checkpoint l_{2j} to checkpoint r_{2j}. It is guaranteed that the larger number of paths is at least twice the smaller number.
Write a program to help Takahashi.
Input Format
The input is given from the standard input in the following format:
$ N $ $ p_1 $ $ q_1 $ $ p_2 $ $ q_2 $ : $ p_N $ $ q_N $ $ Q $ $ t_1 $ $ … $ : $ t_Q $ $ … $
- The first line contains an integer $N\ (2 ≦ N ≦ 2*10^5)$ representing the number of checkpoints.
- The next N lines contain integers $p_i,\ q_i(1 ≦ p_i,\ q_i ≦ 10^6)$ separated by spaces, indicating the positions of the checkpoints.
- The N+2-th line contains an integer $Q(\ 1 ≦ Q ≦ 2*10^5)$ representing the number of queries.
- The next Q lines contain the queries. $ t_j $ indicates the type of the j-th query.
- When $ t_j = 1 $, the line contains $k_j,\ a_j,\ b_j(1 ≦ k_j ≦ N,\ 1 ≦ a_j,\ b_j ≦ 10^6)$ separated by spaces.
- When $ t_j = 2 $, the line contains $l_{1j},\ r_{1j},\ l_{2j},\ r_{2j}\ (1 ≦ l_{1j} < r_{1j} ≦ N,\ 1 ≦ l_{2j} < r_{2j} ≦ N\ )$ separated by spaces.
- For any $ i(1 ≦ i ≦ N-1) $, there is always at least one path from checkpoint i to checkpoint i+1 (even after checkpoint locations are changed by queries), and checkpoints do not overlap.
Output Format
Output the answers for type 2 queries one per line in the order they are given. Output FIRST if the paths from checkpoint l_{1j} to checkpoint r_{1j} are more, and SECOND if the paths from checkpoint l_{2j} to checkpoint r_{2j} are more.
Do not forget the newline at the end.
Sample Input and Output
Sample Input #1
4
1 1
2 5
4 5
5 6
4
2 1 3 3 4
2 1 3 1 4
1 2 2 2
2 2 3 3 4
Sample Output #1
FIRST
SECOND
FIRST
Sample Input #2
4
1 1
100 100
101 102
199 199
3
2 1 2 2 3
2 1 2 2 4
2 1 2 3 4
Sample Output #2
FIRST
FIRST
FIRST
Notes/Hints
Partial Points
This problem has partial points.
- For 30 points, $2 ≦ N ≦ 1,000,\ 1 ≦ Q ≦ 1,000$.
Sample Explanation 1
In the first query, the number of paths from checkpoint 1 to checkpoint 3 is 5. The number of paths from checkpoint 3 to checkpoint 4 is 2. Therefore, output FIRST. In the second query, the number of paths are 5 and 10 respectively, so output SECOND. After the third query changes the location of checkpoint 2, in the fourth query, the number of paths are 10 and 2 respectively, so output FIRST.
Sample Explanation 2
Note that the numbers being compared can be very large.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分