#include <bits/stdc++.h>
using namespace std;
const int C = 1000;
const int inf = (1 << 30) - 1;
const long long linf = (1ll << 62) - 1;
int main() {
  int n;
  cin >> 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;
    if (points[i].first.first % 2 == 1) points[i].first.second *= -1;
  }
  sort((points).begin(), (points).end());
  for (int i = 0; i < n; i++) printf("%d ", points[i].second + 1);
  return 0;
}
