#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int N = 1000005;
const double PI = 4 * atan(1);
const double eps = 1e-7;
const long long oo = 1e10;
const int K = 205;
vector<pair<pair<int, int>, int> > v;
int n;
int batch = 1000;
int sign[N];
int cmp(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) {
  if (a.first.first / batch != b.first.first / batch) {
    return a.first.first < b.first.first;
  }
  return sign[a.first.first / batch] * a.first.second <
         sign[a.first.first / batch] * b.first.second;
}
set<long long> ss;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    v.push_back({{x, y}, i});
    ss.insert(x / batch);
  }
  int pos = 0;
  for (auto t : ss) {
    if (pos % 2 == 0) {
      sign[t] = 1;
    } else {
      sign[t] = -1;
    }
    pos++;
  }
  sort((v).begin(), (v).end(), cmp);
  for (int i = 0; i < n; i++) {
    cout << v[i].second + 1 << " ";
  }
  return 0;
}
