#include <bits/stdc++.h>
using namespace std;
vector<int> v[840][840];
int main() {
  int n;
  srand(time(NULL));
  while (cin >> n) {
    int x, y;
    for (int i = 0; i < n; i++) {
      scanf("%d%d", &x, &y);
      v[x / 1200][y / 1200].push_back(i + 1);
    }
    int top = 0;
    vector<int> ans;
    for (int i = 0; i < 840; i++) {
      if (i % 2 == 0) {
        for (int j = 0; j < 840; j++) {
          if (v[i][j].size() == 0) continue;
          random_shuffle(v[i][j].begin(), v[i][j].end());
          for (int k = 0; k < v[i][j].size(); k++) ans.push_back(v[i][j][k]);
        }
      } else {
        for (int j = 839; j >= 0; j--) {
          if (v[i][j].size() == 0) continue;
          random_shuffle(v[i][j].begin(), v[i][j].end());
          for (int k = 0; k < v[i][j].size(); k++) ans.push_back(v[i][j][k]);
        }
      }
    }
    for (int i = 0; i < n; i++) {
      if (i) printf(" ");
      printf("%d", ans[i]);
    }
    puts("");
  }
}
