#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fll;
const int MAX = 1e6 + 10;
vector<tuple<int, int, int> > all;
void solve(int l, int r, bool isx) {
  if (l == r) return;
  if (isx)
    sort(all.begin() + l, all.begin() + r + 1);
  else
    sort(all.begin() + l, all.begin() + r + 1,
         [&](tuple<int, int, int> a, tuple<int, int, int> b) {
           return get<1>(a) < get<1>(b);
         });
  solve(l, (l + r) / 2, !isx);
  solve((l + r) / 2 + 1, r, !isx);
}
int main() {
  if (!false) ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    all.push_back({x, y, i});
  }
  solve(0, n - 1, true);
  for (auto [x, y, id] : all) cout << id + 1 << ' ';
  cout << '\n';
  return 0;
}
