#include <bits/stdc++.h>
using namespace std;
const int MAX = 1000002;
int n;
struct Point {
  int x, y;
  int idx;
  bool operator<(const Point& P) const {
    if (x / 1000 != P.x / 1000) return x / 1000 < P.x / 1000;
    if ((x / 1000) % 2 == 0)
      return y < P.y;
    else
      return y > P.y;
  }
} arr[MAX];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &arr[i].x, &arr[i].y);
    arr[i].idx = i + 1;
  }
  sort(arr, arr + n);
  for (int i = 0; i < n; i++) cout << arr[i].idx << " ";
  return 0;
}
