After retiring from competitive programming, May decided to become a Pokémon trainer. She has $$$N$$$ Pokémon, and each Pokémon is described by three values: defense ($$$d$$$), health ($$$h$$$), and attack ($$$a$$$).
May is creating a training plan called Chained Training. Her Pokémon are arranged in a line, and the Pokémon at index $$$i$$$ can only fight a Pokémon at index $$$j$$$ such that $$$j \lt i$$$.
When Pokémon $$$i$$$ battles Pokémon $$$j$$$, Pokémon $$$i$$$ gains experience according to the following formula:
$$$$$$ \text{experience}(i, j) = d_j \cdot a_i + \frac{h_j}{d_i} $$$$$$
May has a gym battle soon, so she wants her Pokémon to gain as much experience as possible by fighting against a single Pokémon. For each Pokémon, determine the maximum amount of experience it can gain if she chooses its rival optimally.
The first line contains a single integer $$$N$$$ ($$$1 \leq N \leq 10^6$$$) — the number of Pokémon.
The next $$$N$$$ lines each contain three integers $$$d_i$$$, $$$h_i$$$, and $$$a_i$$$ ($$$1 \leq d_i, h_i, a_i \leq 10^6$$$) — the defense, health, and attack of the $$$i$$$-th Pokémon.
Print $$$N$$$ lines. For each Pokémon $$$i$$$, output two integers — the numerator and denominator of the irreducible fraction representing the maximum experience that the $$$i$$$-th Pokémon can gain.
54 3 175 2 54 1 301 2 28 1 10
0 1 103 5 301 2 12 1 201 4
51 2 103 3 218 2 341 1 164 2 53
0 1 65 3 819 8 130 1 849 2
11 2 3
0 1
| Name |
|---|


