#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
const long long mod = 1e9 + 7;
const long long inf = 1e7;
long long n;
vector<pair<pair<long long, long long>, long long>> vec;
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    long long x, y;
    cin >> x >> y;
    if ((x / 1000) % 2) y = -y;
    vec.push_back({{x / 1000, y}, i});
  }
  sort(vec.begin(), vec.end());
  for (auto i : vec) cout << i.second << ' ';
}
