#include <bits/stdc++.h>
using namespace std;
int n, x[1000009], y[1000009], id[1000009];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d %d", x + i, y + i), id[i] = i;
  sort(id + 1, id + 1 + n, [](int a, int b) {
    if (x[a] / 1000 != x[b] / 1000) return x[a] / 1000 < x[b] / 1000;
    if (x[a] / 1000 % 2) return y[a] > y[b];
    return y[a] < y[b];
  });
  for (int i = 1; i <= n; i++) printf("%d ", id[i]);
}
