#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000009;
struct triple {
  int x, y, i;
};
triple P[MAXN];
bool cmp(triple &t1, triple &t2) {
  int r1 = t1.x / 1000;
  int r2 = t2.x / 1000;
  if (r1 < r2) return true;
  if (r1 > r2) return false;
  if (r1 & 1)
    return t1.y < t2.y;
  else
    return t1.y > t2.y;
}
int main(int argc, char *argv[]) {
  int n;
  scanf("%d", &n);
  for (size_t i = 0; i < n; i++) {
    scanf("%d%d", &P[i].x, &P[i].y);
    P[i].i = i + 1;
  }
  sort(P, P + n, cmp);
  for (size_t i = 0; i < n; i++) printf("%d ", P[i].i);
  puts("");
  return 0;
}
