#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 5;
constexpr int SQRT = 1000;
struct query {
  int x, y, pos;
  short sqrt;
  bool operator<(const query &b) const {
    if (sqrt == b.sqrt) {
      return ((sqrt & 1) ^ y < b.y);
    }
    return sqrt < b.sqrt;
  }
};
query que[MAXN];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> que[i].x >> que[i].y;
    que[i].pos = i + 1, que[i].sqrt = que[i].x / SQRT;
  }
  sort(que, que + n);
  for (int i = 0; i < n; i++) {
    cout << que[i].pos << " ";
  }
  cout << "\n";
}
