#include <bits/stdc++.h>
using namespace std;
bool cmp(const tuple<int, int, int>& a, const tuple<int, int, int>& b) {
  int x1 = get<0>(a) / 1000, x2 = get<0>(b) / 1000;
  if (x1 != x2) return x1 < x2;
  int y1 = get<1>(a), y2 = get<1>(b);
  if (y1 != y2 && x1 % 2 == 0)
    return y1 < y2;
  else if (y1 != y2)
    return y1 > y2;
  return get<2>(a) < get<2>(b);
}
int main() {
  int n, x, y;
  scanf("%d", &n);
  vector<tuple<int, int, int> > arr;
  for (int i = 0; i < n; ++i) {
    scanf("%d %d", &x, &y);
    arr.push_back(make_tuple(x, y, i + 1));
  }
  sort(arr.begin(), arr.end(), cmp);
  for (int i = 0; i < n; ++i) {
    printf("%d ", get<2>(arr[i]));
  }
  return 0;
}
