#include <bits/stdc++.h>
using namespace std;
pair<pair<int, int>, int> a[1000000];
int main() {
  int n, x, y;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &x, &y);
    a[i] = make_pair(make_pair(x / 1000, x / 1000 % 2 ? -y : y), i);
  }
  sort(a, a + n);
  for (int i = 0; i < n; ++i) printf("%d ", a[i].second + 1);
  return 0;
}
