#include <bits/stdc++.h>
using namespace std;
struct node {
  int x, y, id;
  bool operator<(const node &_) const {
    return x < _.x || (x == _.x && (((x & 1) == 1 && y < _.y) ||
                                    ((x & 1) == 0 && y > _.y)));
  }
} A[1000010];
int main() {
  int i, n;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d%d", &A[i].x, &A[i].y);
    A[i].x /= 1000;
    A[i].id = i;
  }
  sort(A + 1, A + 1 + n);
  for (i = 1; i <= n; i++) {
    printf("%d%c", A[i].id, " \n"[i == n]);
  }
  return 0;
}
