#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int N = 1E6 + 7;
int n;
int id[N], x[N], y[N];
bool cmp(int a, int b) {
  if (x[a] < x[b]) return true;
  if (x[a] > x[b]) return false;
  if (x[a] % 2 == 1)
    return y[a] < y[b];
  else
    return y[a] > y[b];
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &x[i], &y[i]);
    x[i] /= 1000;
    y[i] /= 1000;
    id[i] = i;
  }
  sort(id, id + n, cmp);
  for (int i = 0; i < n; i++) {
    printf("%d ", id[i] + 1);
  }
  return 0;
}
