#include <bits/stdc++.h>
using namespace std;
struct pct {
  long long x, y, id;
  pct(int x, int y, int id) {
    this->x = x;
    this->y = y;
    this->id = id;
  }
};
long long n, i, x, y;
vector<pct> v;
bool comp(pct a, pct b) {
  if (a.x / 1000 != b.x / 1000) return a.x < b.x;
  if ((a.x / 1000) % 2)
    return a.y < b.y;
  else
    return a.y > b.y;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> x >> y;
    v.push_back(pct(x, y, i));
  }
  sort(v.begin(), v.end(), comp);
  for (auto it : v) cout << it.id << ' ';
  return 0;
}
