#include <bits/stdc++.h>
using namespace std;
inline long long int gcd(long long int a, long long int b) {
  long long int t;
  while (b) {
    a = a % b;
    t = a;
    a = b;
    b = t;
  }
  return a;
}
using namespace std;
const int MAXN = (long long int)1e6 + 100;
pair<pair<long long, long long>, long long int> arr[MAXN];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long int n;
  cin >> n;
  for (long long int i = 0; i < n; i++) {
    long long int x, y;
    cin >> x >> y;
    arr[i] = make_pair(make_pair(x / 1000, x / 1000 % 2 ? -y : y), i);
  }
  sort(arr, arr + n);
  for (long long int i = 0; i < n; i++) {
    cout << arr[i].second + 1 << " ";
  }
  return 0;
}
