#include <bits/stdc++.h>
using namespace std;
map<int, int> c[1000006];
vector<int> ans;
vector<pair<int, int>> p[1005];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    p[x / 1000].push_back({y, x});
    c[x][y] = i;
  }
  for (int i = 0; i <= 1000; i++) {
    if (i % 2 == 0) {
      sort(p[i].begin(), p[i].end());
      for (auto j : p[i]) {
        int v = c[j.second][j.first];
        ans.push_back(v);
      }
    } else {
      sort(p[i].begin(), p[i].end());
      reverse(p[i].begin(), p[i].end());
      for (auto j : p[i]) {
        int v = c[j.second][j.first];
        ans.push_back(v);
      }
    }
  }
  for (auto x : ans) {
    cout << x << " ";
  }
  cout << endl;
}
