#P6393. 隔离的日子

隔离的日子

Description

In the past, Tianyi would line up the nn chestnuts she bought into a row, numbered from left to right as 1,2,,n1,2,\cdots ,n. The ii-th chestnut has sweetness aia_i and saltiness bib_i.

Tianyi believes that sweetness and saltiness should be balanced, so she defines a perfect pairing (i,j)(i,j), where i,ji,j are the indices of two chestnuts. Specifically, (i,j)(i,j) is called a perfect pairing if and only if jj is the smallest among all jj satisfying i<jni<j \leq n and $(a_j-b_i) \times (b_j+b_i)=a_j \times b_i + a_i \times b_j$. It is not hard to see that for a fixed ii, the perfect pairing is uniquely determined.

Now Tianyi wants to know, for each chestnut ii, which chestnut forms a perfect pairing with it.

Input Format

The first line contains an integer nn, meaning Tianyi lined up nn chestnuts in a row.

The next nn lines each contain two integers aia_i and bib_i, representing the sweetness and saltiness of the ii-th chestnut, respectively.

Output Format

Output nn lines in total. Each line contains one integer. The ii-th line should output the jj in the perfect pairing (i,j)(i,j) for the ii-th chestnut.

In particular, if there is no jj that forms a perfect pairing with ii, then output -1 on the ii-th line.

5
6 8
22 8
15 4
23 4
31 4
2
-1
4
5
-1

Hint

Sample Explanation #1

For the first chestnut: (228)×(8+8)=22×8+6×8(22 - 8) \times (8 + 8) = 22 \times 8 + 6 \times 8, so the output is 22.

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 44.

For the fourth chestnut: $(31 - 4) \times (4 + 4) = 31 \times 4 + 23 \times 4$, so the output is 55.

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), n103n \leq 10^3.
  • Subtask 2 (70 Points), n5×104n \leq 5 \times 10^4.

For 100%100\% of the testdata, 1n5×1041 \leq n \leq 5 \times 10^4, 1ai1091 \leq a_i \leq 10^9, 1bi1001 \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