You are tasked with building a high-security prison cell, which should consist of a room located inside another room. The laws allow for the construction of rooms of strictly one of $$$n$$$ types, where the $$$i$$$-th type is a rectangle with dimensions $$$a_i$$$ from west to east and $$$b_i$$$ from north to south (but not vice versa). A room of size $$$a_i \times b_i$$$ can be placed inside a room of size $$$a_j \times b_j$$$ if and only if $$$a_i \leq a_j$$$ and $$$b_i \leq b_j$$$. For safety reasons, the outer and inner rooms must be of different types (but not necessarily different sizes).
Of course, it is not true for any two rooms that one can fit inside the other. For example, rooms of sizes $$$4 \times 6$$$ and $$$5 \times 3$$$ cannot be placed one inside the other, as $$$4 \lt 5$$$, but $$$6 \gt 3$$$. Therefore, if the warden insists that the inner room must be of type $$$i$$$ and no other, you are allowed to make an exception and choose any type $$$j \neq i$$$ and "expand" the room $$$a_j \times b_j$$$ to $$$a \times b$$$ to make it an outer room (that is, choose arbitrary $$$a \geq a_j$$$, $$$b \geq b_j$$$) paying the fee of $$$(a + b) - (a_j + b_j)$$$ in order for the room of type $$$i$$$ to fit inside it.
Clearly the warden wants to spend as little money as possible but he does not want to risk safety. Therefore, before making a final choice, he wants to estimate the minimum amount he will have to pay to the government if the inner room is of type $$$i$$$, for each $$$i$$$ from $$$1$$$ to $$$n$$$.
The first line of input contains a single integer $$$n$$$ — the number of types of rooms officially allowed in the city ($$$2 \leq n \leq 2 \cdot 10^5$$$).
In each of the following $$$n$$$ lines, the integers $$$a_i$$$ and $$$b_i$$$ are given representing the dimensions of the $$$i$$$-th type of room ($$$1 \leq a_i, b_i \leq 10^9$$$). It is not guaranteed that all types correspond to different room sizes. If there are two types with the same dimensions, rooms of these types can fit inside each other.
Output $$$n$$$ integers separated by spaces, where the $$$i$$$-th integer is the minimum amount of money that must be paid to build a high-security cell with an inner room of type $$$i$$$.
31 32 23 1
1 1 1
54 46 33 32 51 1
1 2 0 1 0
| Name |
|---|


