#include <bits/stdc++.h>
const int MAX = 1e3 + 11;
using namespace std;
int N;
vector<pair<int, int>> A[MAX];
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    int x = 0, y = 0;
    scanf("%d %d", &x, &y);
    A[x / MAX].push_back({y, i});
  }
  for (int i = 0; i < MAX; ++i) {
    for (int j = i + 1; j < MAX; ++j) {
      if (A[i].size() < A[j].size()) {
        swap(A[i], A[j]);
      }
    }
  }
  int sz = 0;
  for (int i = 0; i < MAX; ++i) {
    if (!A[i].size()) {
      sz = i + 1;
      break;
    }
  }
  for (int j = 0; j < sz; ++j) {
    if (j & 1) {
      sort(A[j].begin(), A[j].end());
    } else {
      sort(A[j].rbegin(), A[j].rend());
    }
  }
  vector<int> res;
  for (int i = 0; i < sz; ++i) {
    for (int j = 0; j < A[i].size(); ++j) {
      res.push_back(A[i][j].second);
    }
  }
  for (int k = 0; k < res.size(); ++k) {
    printf("%d ", res[k] + 1);
  }
  return 0;
}
