#include <bits/stdc++.h>
using namespace std;
const long double Pi = 3.14159265359;
const long long MOD = (long long)1e9 + 7;
const long long MAXN = (long long)1e6 + 10;
const long long INF = (long long)9223372036854775807;
pair<long long, long long> a[MAXN];
long long b[MAXN];
long long dis = 1500ll;
bool CMP(long long i, long long j) {
  if (a[i].second / dis == a[j].second / dis) {
    if (a[i].first == a[j].first) return a[i].first < a[j].first;
    return a[i].first < a[j].first;
  }
  return a[i].second / dis < a[j].second / dis;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i].first >> a[i].second;
  for (int i = 0; i < n; i++) b[i] = i;
  sort(b, b + n, CMP);
  for (int i = 0; i < n; i++) cout << b[i] + 1 << " ";
  return 0;
}
