#include <bits/stdc++.h>
using namespace std;
vector<int> v[1003][1003];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    int xrgn = x / 1200, yrgn = y / 1200;
    v[xrgn][yrgn].push_back(i);
  }
  for (int i = 0; i < 1002; i++) {
    if (i % 2 == 0) {
      for (int j = 0; j < 1002; j++) {
        for (int k = 0; k < v[i][j].size(); k++) {
          cout << v[i][j][k] + 1 << " ";
        }
      }
    } else {
      for (int j = 1002; j >= 0; j--) {
        for (int k = 0; k < v[i][j].size(); k++) {
          cout << v[i][j][k] + 1 << " ";
        }
      }
    }
  }
}
