using System;
using System.Linq;
using System.Collections.Generic;
class TapePos
{
public readonly int wrap;
public readonly double distance;
public readonly int index;
public TapePos(int wrap, double distance, int index)
{
this.wrap = wrap;
this.distance = distance;
this.index = index;
}
}
class main
{
private static List<TapePos> reorder(List<TapePos> points)
{
List<TapePos> forward = new List<TapePos>();
List<TapePos> backward = new List<TapePos>();
for (int i = 0; i < points.Count; i++)
{
if (points[i].wrap % 2 == 0)
forward.Add(points[i]);
else
backward.Add(points[i]);
}
forward = forward.OrderBy(x => x.distance).ToList();
backward = backward.OrderByDescending(x => x.distance).ToList();
return forward.Concat(backward).ToList();
}
public static void Main(string[] args)
{
int n = Int32.Parse(Console.ReadLine());
List<TapePos> points = new List<TapePos>();
for (int i = 0; i < n; i++)
{
string[] line = Console.ReadLine().Split(' ');
int w = Int32.Parse(line[0]);
double d = Double.Parse(line[1]);
points.Add(new TapePos(w, d, i));
}
List<TapePos> order = reorder(points);
for (int i = 0; i < order.Count; i++)
{
System.Console.Write("{0} ", order[i].index);
}
System.Console.WriteLine();
}
}