#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const int inf = 0x3f3f3f3f;
const double eps = 1e-15;
const long long INF = (1LL << 60);
const int N = 1001000;
struct Point {
  int id, blockid, l, r;
  bool operator<(const Point &b) const {
    if (blockid != b.blockid) {
      return blockid < b.blockid;
    }
    if (blockid & 1) {
      return b.r < r;
    }
    return r < b.r;
  }
} p[N];
int main() {
  int n;
  int bsize = 1000;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &p[i].l, &p[i].r);
    p[i].blockid = p[i].l / bsize;
    p[i].id = i;
  }
  sort(p + 1, p + n + 1);
  for (int i = 1; i <= n; ++i) {
    printf("%d ", p[i].id);
  }
  return 0;
}
