#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000005;
int S;
int n;
struct ppp {
  int x, y, id, block, mark;
  void read(int _id) {
    scanf("%d%d", &x, &y);
    id = _id;
    block = x / S;
    mark = block % 2;
  }
} node[maxn];
int cmp(ppp a, ppp b) {
  if (a.block != b.block) return a.block < b.block;
  if (a.mark == 0) {
    return a.y > b.y;
  } else
    return a.y < b.y;
}
int main() {
  while (~scanf("%d", &n)) {
    S = sqrt(n);
    if (S <= 0) S = 1;
    for (int i = 1; i <= n; i++) node[i].read(i);
    sort(node + 1, node + 1 + n, cmp);
    for (int i = 1; i <= n; i++) printf("%d ", node[i].id);
    printf("\n");
  }
}
