#include <bits/stdc++.h>
using namespace std;
const int C = 1000;
int compare(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) {
  return a.first.first < b.first.first ||
         (a.first.first == b.first.first &&
          (a.first.first % 2 == 0 ? (a.first.second < b.first.second)
                                  : (a.first.second > b.first.second)));
}
int main() {
  int n;
  scanf("%d", &n);
  vector<pair<pair<int, int>, int> > points(n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &points[i].first.first, &points[i].first.second);
    points[i].second = i;
    points[i].first.first /= C;
  }
  sort((points).begin(), (points).end(), compare);
  for (auto i : points) {
    printf("%d ", i.second + 1);
  }
  printf("\n");
  return 0;
}
