#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > arr;
vector<int> buck[1005];
int cmp(int a, int b) { return arr[a].second < arr[b].second; }
int main() {
  int n;
  scanf("%d", &n);
  int x, y;
  int minim = 1000000, maxim = 1;
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &x, &y);
    arr.push_back(make_pair(x, y));
    minim = min(minim, x);
    maxim = max(maxim, x);
  }
  int size = (int)sqrt((double)maxim - minim);
  if (size == 0) size = (int)1e6;
  for (int i = 0; i < n; i++) {
    buck[(arr[i].first - minim) / size].push_back(i);
  }
  bool op = false;
  for (int i = 0; i <= (maxim - minim) / size; i++) {
    if (buck[i].size() == 0) continue;
    sort(buck[i].begin(), buck[i].end(), cmp);
    for (int j = 0; j < (int)buck[i].size(); j++) {
      if (op)
        printf(" ");
      else
        op = true;
      printf("%d", buck[i][j] + 1);
    }
  }
  printf("\n");
}
