#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
struct Point {
  int x, y, id;
  void read(int id) {
    this->id = id;
    scanf("%d%d", &x, &y);
  }
} p[N];
bool cmp(Point a, Point b) {
  if (a.x / 2500 == b.x / 2500) return a.y < b.y;
  return a.x < b.x;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) p[i].read(i + 1);
  sort(p, p + n, cmp);
  for (int i = 0; i < n; i++) printf("%d ", p[i].id);
  return 0;
}
