#include <bits/stdc++.h>
using namespace std;
struct P {
  int x, y;
  int i;
  bool operator<(const P& p) const {
    int yy = y / 1000;
    int yy2 = p.y / 1000;
    if (yy != yy2) return yy < yy2;
    return yy & 1 ? x < p.x : x > p.x;
  }
};
P ps[1 << 20];
int main() {
  cin.sync_with_stdio(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    P& p = ps[i];
    cin >> p.x >> p.y;
    p.i = 1 + i;
  }
  sort(ps, ps + n);
  for (int i = 0; i < n; ++i) {
    cout << ps[i].i << ' ';
  }
  cout << '\n';
}
