class TapePos:
def __init__(self, wrap, distance, index):
self.wrap = wrap
self.distance = distance
self.index = index
def reorder(points):
forward = []
backward = []
for tape_pos in points:
if tape_pos.wrap % 2 == 0:
forward.append(tape_pos)
else:
backward.append(tape_pos)
forward.sort(key=lambda x: x.distance)
backward.sort(key=lambda x: x.distance, reverse=True)
return forward + backward
if __name__ == "__main__":
n = int(input())
points = []
for i in range(n):
inp = input().split()
w = int(inp[0])
d = float(inp[1])
points += [TapePos(w, d, i)]
order = reorder(points)
print(' '.join(str(x.index) for x in order))