#include <bits/stdc++.h>
using namespace std;
struct point {
  int id, x, y, bl;
};
bool operator<(const point& _1, const point& _2) {
  if (_1.bl != _2.bl) return _1.bl < _2.bl;
  if (_1.bl & 1) return _1.y < _2.y;
  return _1.y > _2.y;
}
const int MAX_N = (int)1e6 + 6;
struct point p[MAX_N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &p[i].x, &p[i].y);
    p[i].id = i + 1;
    p[i].bl = p[i].x / 1000;
  }
  sort(p, p + n);
  for (int i = 0; i < n; i++) printf("%d%c", p[i].id, "\n "[i < n]);
  return 0;
}
