#include <bits/stdc++.h>
using namespace std;
using K = long double;
using PII = pair<int, int>;
using PKK = pair<K, K>;
const int N = 1e6;
PII p[N];
map<PII, int> M;
bool xgty(PII a) { return a.first > a.second; }
K dst(PII xy, PKK a) {
  return abs(xy.first - a.first) + abs(xy.second - a.second);
}
void order(PII* begin, PII* end, PKK a, PKK b, PKK c) {
  if (end - begin <= 1) return;
  PII* ptr =
      partition(begin, end, [a, c](PII xy) { return dst(xy, a) < dst(xy, c); });
  PKK d = make_pair(0.5L * (a.first + c.first), 0.5L * (a.second + c.second));
  order(begin, ptr, a, d, b);
  order(ptr, end, b, d, c);
}
int main() {
  int n;
  assert(scanf("%d", &n));
  for (int i = 0; i < (n); i++) {
    assert(scanf("%d%d", &p[i].first, &p[i].second) == 2);
    M[p[i]] = i;
  }
  int k = partition(p, p + n, xgty) - p;
  order(p, p + k, make_pair(-1e6L, -1e6L), make_pair(1e6L, -1e6L),
        make_pair(1e6L, 1e6L));
  order(p + k, p + n, make_pair(-1e6L, -1e6L), make_pair(-1e6L, 1e6L),
        make_pair(1e6L, 1e6L));
  for (int i = 0; i < (n); i++) printf("%d ", M[p[i]] + 1);
  printf("\n");
}
