#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e6 + 7;
const long long mod = 1e9 + 7;
const long long INF = 1e9 + 7;
const long long mlog = 20;
const long long SQRT = 1000;
long long x[maxn], y[maxn], ord[maxn];
bool cmp(long long a, long long b) {
  if (x[a] / SQRT == x[b] / SQRT)
    return (x[a] / SQRT % 2 ? y[a] < y[b] : y[a] > y[b]);
  return x[a] / SQRT < x[b] / SQRT;
}
int32_t main() {
  ios_base::sync_with_stdio(false), cin.tie(), cout.tie();
  ;
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> x[i] >> y[i], ord[i] = i;
  sort(ord, ord + n, cmp);
  for (long long i = 0; i < n; i++) cout << ord[i] + 1 << " ";
  return 0;
}
