#include <bits/stdc++.h>
using namespace std;
int n, block;
struct point {
  int x, y, id, pos;
} a[1000010];
inline bool operator<(point a, point b) {
  if (a.pos == b.pos) {
    if (a.pos & 1) return a.y < b.y;
    return a.y > b.y;
  }
  return a.pos < b.pos;
}
int main() {
  scanf("%d", &n);
  block = 1000;
  for (int i = 1; i <= n; i++)
    scanf("%d%d", &a[i].x, &a[i].y), a[i].id = i,
                                     a[i].pos = (a[i].x - 1) / block + 1;
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) printf("%d ", a[i].id);
  return 0;
}
