#include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
const int maxn = 1000000 + 100;
int x[maxn];
int y[maxn];
vector<pair<int, int> > b[maxn / 1000 + 50];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < (n); i++) {
    scanf("%d%d", &x[i], &y[i]);
    int f = x[i] / 1000;
    if (f % 2 == 0)
      b[f].push_back(make_pair(y[i], i + 1));
    else
      b[f].push_back(make_pair(-y[i], i + 1));
  }
  for (int f = 0; f < (1010); f++) {
    sort((b[f]).begin(), (b[f]).end());
    for (int i = 0; i < (((int)(b[f]).size())); i++)
      cout << b[f][i].second << " ";
  }
  cout << '\n';
  return 0;
}
