#include <bits/stdc++.h>
using namespace std;
struct Point {
  int l, r, index, block;
  Point() {}
  Point(int l, int r, int index) : l(l), r(r), index(index) {}
  void get_block(int d) { block = l / d; }
  bool operator<(const Point& p) const {
    if (block != p.block) return block < p.block;
    return r < p.r;
  }
} p[1000005];
int n;
int main() {
  scanf("%d", &n);
  int d = 1500;
  for (int i = 0; i < (int(n)); i++) {
    scanf("%d%d", &p[i].l, &p[i].r);
    p[i].index = i;
    p[i].get_block(d);
  }
  sort(p, p + n);
  for (int i = 0; i < (int(n)); i++) {
    if (i) printf(" ");
    printf("%d", p[i].index + 1);
  }
  puts("");
  return 0;
}
