Seats 2
InterviewTime limit2sMemory limit1024 MB
For each player, find the smallest seat distance to a player from a different country when N players sit on a line.
Problem
The JOI country is holding a programming world competition this year. players are scheduled to attend, numbered from 1 to .
Each player's home country is an integer from 1 to . Player () is from country . Not all players are from the same country. Each player's seat lies on a straight line, and player () sits at position . The seat distance between player and player () is , where is the absolute value of .
During the competition, each player wants to know the seat distance to the nearest player from a different country.
Given each player's country and seat position, print for each player () the smallest seat distance from player to a player from a different country.
Input
N
C1 X1
C2 X2
⋮
CN XN
Output
Print lines. On line (), print the seat distance from player to the nearest player whose country differs from player 's country.
Constraints
- .
- ().
- ().
- Not all players are from the same country.
- All input values are integers.