import java.util.*;
class TapePos implements Comparable<TapePos> {
final public int wrap;
final public double distance;
final public int index;
public TapePos(int wrap, double distance, int index) {
this.wrap = wrap;
this.distance = distance;
this.index = index;
}
@Override
public int compareTo(TapePos other) {
return Double.compare(distance, other.distance);
}
}
public class quickstart {
private static List<TapePos> reorder(List<TapePos> points) {
List<TapePos> forward = new ArrayList<TapePos>();
List<TapePos> backward = new ArrayList<TapePos>();
for (int i = 0; i < points.size(); i++) {
if (points.get(i).wrap % 2 == 0)
forward.add(points.get(i));
else
backward.add(points.get(i));
}
Collections.sort(forward);
Collections.sort(backward);
Collections.reverse(backward);
List<TapePos> result = new ArrayList(forward);
result.addAll(backward);
return result;
}
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
List<TapePos> points = new ArrayList<TapePos>();
for (int i = 0; i < n; i++)
{
int w = in.nextInt();
double d = in.nextDouble();
points.add(new TapePos(w, d, i));
}
List<TapePos> order = reorder(points);
for (int i = 0; i < order.size(); i++)
{
System.out.print("" + order.get(i).index + " ");
}
System.out.println();
}
}