P6393 Days in Isolation
Background
(Background adapted from Baidu Tieba / Nanbei Group Backup Bar / Cute Nanbei Daily / F9023, by author [落墨成白](https://tieba.baidu.com/home/main/?un=%E8%93%93%E8%90%BD%E9%B1%BC&ie=utf-8&id=tb.1.a8bcbb73.CMcL9PXngjHz-dKRJ7_T4A&fr=frs).)
### The data has been fixed.
Day after day, whenever late night came and only the glow of a phone screen was left in the room, Luo Tianyi would always feel a sense of loss, as if she had been cut off from the world.
On days when she hid under the quilt, lonely enough to want to cry, she began to miss those little days of being busy with work, mixed with a bit of fear, unease, and trouble.
The harsh sunlight, the urge to go out, and the small worry about not wanting to get tanned tangled together, filling her heart with these complicated little feelings.
If possible, she would also want a fruit platter. A-Ling always said she could not have cold things, so when A-Ling was not paying attention, she would soak both hands into a bucket full of water, glancing at A-Ling’s helpless look, and feeling refreshed.
Even when she thought back on it late at night, it still felt unforgettable. But when she was alone, turning on the faucet and letting the cold water run over her arms, she could not find the happiness from back then.
People say that when you choose to briefly forget about life, you will gain a tiny bit of happiness.
But why did those scenes in her mind become clearer and clearer?
In the past, whenever it was a holiday, warm sunlight would shine in through the glass. A-Ling would lie on the rocking chair, and she could cling to A-Ling’s arms and rest softly. A whole noon would pass like that, like a “raising” mobile game, a great way to kill time.
There was also that roasted chestnut shop at the street corner. She would pull A-Ling to stand at the storefront, watching the glossy chestnuts “dance” as they bounced in the stir-frying machine, with an enticing smell coming from the cracked seams.
She would pester A-Ling to buy a few jin and pack them up, but the annoying A-Ling would not give them to her. Instead, A-Ling would calmly fish one out of the bag, give it a gentle squeeze and the chestnut would pop open, then gently break it apart and the chestnut meat would appear intact right in front of her. At that moment, she only needed to open her mouth. A-Ling would indulgently feed the chestnut into her mouth, and as long as she saw her satisfied squinting expression, A-Ling would also show a happy smile.
She could not help but smile bitterly. She even had a whole set of in-depth research on chestnuts herself—
Description
In the past, Tianyi would line up the $n$ chestnuts she bought into a row, numbered from left to right as $1,2,\cdots ,n$. The $i$-th chestnut has sweetness $a_i$ and saltiness $b_i$.
Tianyi believes that sweetness and saltiness should be balanced, so she defines a perfect pairing $(i,j)$, where $i,j$ are the indices of two chestnuts. Specifically, $(i,j)$ is called a perfect pairing if and only if $j$ is the **smallest** among all $j$ satisfying $i
Input Format
The first line contains an integer $n$, meaning Tianyi lined up $n$ chestnuts in a row.
The next $n$ lines each contain two integers $a_i$ and $b_i$, representing the sweetness and saltiness of the $i$-th chestnut, respectively.
Output Format
Output $n$ lines in total. Each line contains one integer. The $i$-th line should output the $j$ in the **perfect pairing $(i,j)$** for the $i$-th chestnut.
In particular, if there is no $j$ that forms a **perfect pairing** with $i$, then output `-1` on the $i$-th line.
Explanation/Hint
#### Sample Explanation #1
For the first chestnut: $(22 - 8) \times (8 + 8) = 22 \times 8 + 6 \times 8$, so the output is $2$.
The second chestnut has no perfect pairing that satisfies the condition.
For the third chestnut: $(23 - 4) \times (4 + 4) = 23 \times 4 + 15 \times 4$, so the output is $4$.
For the fourth chestnut: $(31 - 4) \times (4 + 4) = 31 \times 4 + 23 \times 4$, so the output is $5$.
Because the fifth chestnut is the last chestnut, it has no perfect pairing that satisfies the condition.
---
#### Constraints
**This problem uses bundled testdata.**
- Subtask 1 (30 Points), $n \leq 10^3$.
- Subtask 2 (70 Points), $n \leq 5 \times 10^4$.
For $100\%$ of the testdata, $1 \leq n \leq 5 \times 10^4$, $1 \leq a_i \leq 10^9$, $1 \leq b_i \leq 100$.
---
### Background (Continued)
The taste became more and more real, and the aroma of chestnuts seemed to still linger at the tip of her nose…
Taste? Luo Tianyi suddenly got up and walked out of the bedroom. Across a door barrier, she looked at her.
“Are you stupid? I’m in isolation right now. What are you doing here?” With surprise and worry, Luo Tianyi suddenly burst into tears.
Yuezheng Ling scratched her head. The warmth of the chestnuts passed through the paper bag to her palm, like a warm pack held in the hands on cold days.
“There was an infected case on my return train, so I also need to be isolated. They asked me where my home is, and I gave them your address.”
Yuezheng Ling peeled the shell, pinched one, and put it into the little crybaby’s mouth.
The chestnut fragrance drifted around the corners of their mouths. “The time has to be extended again…” Tianyi muttered with slight panting, but deep down she had a bit more happy anticipation. Actually, if A-Ling was here, it was not that bad to stay in the room a little longer.
“Ah, I’m very sorry.” Yuezheng Ling smiled softly. She did not know whether it was because of the precious time again, or because her fingers had brushed over the corner of Tianyi’s reddened lips.
Translated by ChatGPT 5