P11109 [ROI 2023] Meeting (Day 2)

Background

Translated from [ROI 2023 D2T2](https://neerc.ifmo.ru/school/archive/2022-2023/ru-olymp-roi-2023-day2.pdf)。 The Peruvian Association of Science and Education is organizing a conference and plans to hold $n$ activities, numbered from $1$ to $n$. Let $l_i$ and $r_i$ be the start and end times of activity $i$, respectively. Since some activities may overlap, a person may not be able to attend all of them. Activities $i$ and $j$ are considered non-conflicting if $r_i < l_j$ or $r_j < l_i$. A set of activities is called compatible if every two different activities in the set are non-conflicting. Suppose the maximum size of a compatible set is $m$. The saturation of the conference is defined as $\frac{n}{m}$. Due to budget cuts, the organizers decided to reduce the number of conference activities by half. At the same time, they want the saturation to remain unchanged, so in the reduced set of activities, the maximum size of a compatible set must also be reduced by half. It is guaranteed that, in the original conference plan, both the number of activities $n$ and the maximum compatible set size $m$ are even.

Description

Help the organizers choose $\frac{n}{2}$ activities from the plan so that the maximum size of a compatible set among the chosen activities is $\frac{m}{2}$.

Input Format

Each test contains multiple test cases. The first line contains an integer $t$, the number of test cases ($1 \le t \le 50000$). The first line of each test case contains an integer $n$, the number of activities in the original plan ($2 \le n \le 100000$, and $n$ is even). In the next $n$ lines, the activities are described. Each line contains two integers $l_i$ and $r_i$, the start and end times of activity $i$ ($1 \le l_i < r_i \le 10^9$). It is guaranteed that the maximum compatible set size $m$ in the original plan is even, and $\sum n\le100000$.

Output Format

For each test case, output $\frac{n}{2}$ distinct activity indices in one line, representing the activities that will be kept. If there are multiple valid answers, output any of them. The maximum size of a compatible set among the selected activities must be $\frac{m}{2}$.

Explanation/Hint

Sample explanation: ![](https://cdn.luogu.com.cn/upload/image_hosting/7qt38uep.png) The figure above shows the initial set of activities in the first test case. One possible maximum compatible set is marked with a thick dashed line. ![](https://cdn.luogu.com.cn/upload/image_hosting/m7k9p90a.png) The figure above shows the set of activities in one valid answer for the first test case. One possible maximum compatible set is marked with a thick dashed line. ![](https://cdn.luogu.com.cn/upload/image_hosting/j4o9mevq.png) The initial set of activities in the second test case. ![](https://cdn.luogu.com.cn/upload/image_hosting/bu7gii0j.png) The set of activities in one valid answer for the second test case. Let $N=\sum n$. We say that activity $i$ completely covers activity $j$ if and only if $l_i\le l_j