#include <bits/stdc++.h>
using namespace std;
vector<long long> P[1100][1100];
long long S = 1000, n;
void work(vector<long long> &T, long long code) {
  if (!code)
    sort(T.begin(), T.end());
  else
    sort(T.rbegin(), T.rend());
  for (long long v : T) cout << v << " ";
}
void xuly() {
  for (long long i = 0; i <= 1000; ++i) {
    if (i % 2 == 0) {
      for (long long j = 0; j <= 1000; ++j) {
        work(P[i][j], 0);
      }
    } else {
      for (long long j = 1000; j >= 0; --j) {
        work(P[i][j], 1);
      }
    }
  }
}
void nhap() {
  long long x, y;
  cin >> n;
  for (long long i = 1; i <= n; ++i) {
    cin >> x >> y;
    P[x / S][y / S].push_back(i);
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  nhap();
  xuly();
  return 0;
}
