#include <bits/stdc++.h>
using namespace std;
const int nmax = 1000;
struct pct {
  int x, y, ind;
  pct() {}
  pct(int _x, int _y, int _ind) : x(_x), y(_y), ind(_ind) {}
  inline bool operator<(const pct &a) const { return (x < a.x); }
};
vector<pct> v[nmax + 1];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    v[y / nmax].push_back(pct(x, y, i));
  }
  for (int f = 0; f <= nmax; ++f) {
    sort(v[f].begin(), v[f].end());
    if (f % 2 == 1) {
      for (int i = 0; i < (int)v[f].size(); ++i) {
        printf("%d ", v[f][i].ind);
      }
    } else {
      for (int i = (int)v[f].size() - 1; i >= 0; --i) {
        printf("%d ", v[f][i].ind);
      }
    }
  }
  return 0;
}
