Jihoon plays a computer game with several players in it. Each player controls one ball that has a fixed color and a fixed size. A player scores by capturing a ball that is strictly smaller than their own ball and has a different color, and the score gained is the size of the captured ball. A ball of the same size cannot be captured even when its color differs. Capturing another ball does not change the color or the size of your own ball.
Consider four balls. Colors are written as numbers for convenience.
| Ball | Color | Size |
|---|---|---|
| 1 | 1 | 10 |
| 2 | 3 | 15 |
| 3 | 1 | 3 |
| 4 | 4 | 8 |
Ball 2 captures all three other balls. Ball 1 cannot capture ball 2, which is larger, and cannot capture ball 3, which has the same color, so it captures only ball 4.
Given the color and the size of every ball, print for each player the total size of all balls that player can capture.
The first line contains the number of balls N (1≤N≤200000).
Each of the next N lines contains the color Ci and the size Si of the i-th ball, separated by a space (1≤Ci≤N, 1≤Si≤2000). Several balls may share a color, and several balls may share a size.
Print N lines. The i-th line contains the total size of all balls that the player controlling the i-th ball can capture.