#include <bits/stdc++.h>
using namespace std;
const double PI = 3.141592653589793;
const int L = 1000;
int n;
int x[1000010], y[1000010];
int f[1000010];
int ans[1000010];
void init() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &x[i], &y[i]);
    f[i] = (x[i] / L);
    if (f[i] % 2)
      f[i] = f[i] * L + y[i] / L;
    else
      f[i] = f[i] * L + L - y[i] / L;
    ans[i] = i;
  }
}
bool cmp(int a, int b) { return f[a] < f[b]; }
void work() {
  sort(ans + 1, ans + n + 1, cmp);
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
}
int main() {
  init();
  work();
  return 0;
}
