Under construction

Still being built. Things may change

Drone Elimination

Interview

Time limit2sMemory limit1024 MB

Summary
Given n drone positions, find a shooting order so that no drone reaches the origin when drones move one step in any of 8 directions after each shot, or report -1.
Level

Medium5 of 10

Topics
Greedy, Sorting
Solved
No attempts yet

Statement

Ralph escaped from his game, so nn specially trained drones were sent to find him. Ralph is not easy to catch, though, and he has set up a defensive position with a turret in his hands.

After studying the situation, Ralph worked out that on a plane with him at the origin (0,0)(0, 0), drone ii is at the point (xi,yi)(x_i, y_i). While Ralph was scouting, the drones spotted him, so he has to act now. Each second, Ralph can shoot any one drone with his turret. After each shot, every surviving drone can move to any of the 8 points adjacent to it horizontally, vertically, or diagonally. Several drones may end up at the same coordinates.

The drones want to reach Ralph at (0,0)(0, 0), and Ralph wants to destroy all of them before they reach him. Ralph guarantees that he never misses and that each shot destroys exactly one drone. Tell him the order in which to shoot the drones so that none of them reaches (0,0)(0, 0). If that is impossible, say so, and Ralph should run.

Input

The first line contains the number of drones nn (1≤n≤1051 \le n \le 10^5). Each of the next nn lines contains two integers xix_i and yiy_i, the coordinates of drone ii (∣xi∣,∣yi∣≤105|x_i|, |y_i| \le 10^5). It is guaranteed that no drone is at (0,0)(0, 0).

Output

Print nn integers from 1 to nn on a single line, separated by spaces. These are the numbers of the drones in the order Ralph should shoot them. If some drone reaches (0,0)(0, 0) no matter what, print "-1" on a single line. If several solutions exist, you may print any of them.

Examples2

  1. Example 1

    Input
    3
    0 1
    -2 3
    2 2
    
    Expected output
    1 3 2
    
  2. Example 2

    Input
    3
    0 1
    -2 2
    2 2
    
    Expected output
    -1