#include <bits/stdc++.h>
using namespace std;
struct point {
  int i, x, y;
  point() {}
  point(int _i, int _x, int _y) : i(_i), x(_x), y(_y) {}
  bool operator<(const point &rhs) const {
    if (x / 1000 != rhs.x / 1000) return x / 1000 < rhs.x / 1000;
    if ((x / 1000) & 1) return y < rhs.y;
    return y > rhs.y;
  }
} p[1000000];
int main() {
  int n, x, y;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &x, &y);
    p[i] = point(i + 1, x, y);
  }
  sort(p, p + n);
  for (int i = 0; i < n; i++) {
    if (i) putchar(' ');
    printf("%d", p[i].i);
  }
  puts("");
  return 0;
}
