#include <bits/stdc++.h>
using namespace std;
const int maxx = 1000024;
const int buck = 1101;
const long long mn = 25 * 100000000ll;
vector<int> buckets[buck];
pair<int, int> point[maxx];
long long dist(pair<int, int> a, pair<int, int> b) {
  return abs(a.first - b.first) + abs(a.second - b.second);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int e = 0; e < n; e++) {
    int x, y;
    cin >> x >> y;
    buckets[x / buck].push_back(e);
    point[e] = make_pair(x, y);
  }
  vector<int> ans;
  for (int e = 0; e < buck; e++) {
    if (buckets[e].size() == 0) continue;
    sort(buckets[e].begin(), buckets[e].end(),
         [&](int a, int b) { return point[a].second < point[b].second; });
    for (auto &it : buckets[e]) ans.push_back(it);
  }
  long long d = 0;
  for (int e = 0; e < ans.size() - 1; e++)
    d += dist(point[ans[e]], point[ans[e + 1]]);
  assert(d <= mn);
  for (int e = 0; e < ans.size(); e++)
    cout << ans[e] + 1 << " \n"[e == ans.size() - 1];
  return 0;
}
