#include <bits/stdc++.h>
using namespace std;
int n;
vector<pair<pair<int, int>, int> > v;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x, y;
    cin >> x >> y;
    v.push_back(pair<pair<int, int>, int>(pair<int, int>(x / 2012, y), i));
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < v.size(); i++) cout << v[i].second << ' ';
}
