#include <bits/stdc++.h>
using namespace std;
int next_int() {
  int x = 0;
  char c = getchar();
  while (!isdigit(c)) {
    c = getchar();
  }
  for (; isdigit(c); c = getchar()) {
    x = x * 10 + c - '0';
  }
  return x;
}
struct my {
  int x, y, z, numb;
} a[2000000];
inline char o1(my a, my b) {
  if (a.numb == b.numb && a.numb % 2 == 0) {
    if (a.y > b.y)
      return true;
    else
      return false;
  } else if (a.numb == b.numb && a.numb % 2 == 1) {
    if (a.y < b.y)
      return true;
    else
      return false;
  } else if (a.numb < b.numb)
    return true;
  else
    return false;
}
int main() {
  int n = next_int();
  for (int i = 0; i < n; i++) {
    a[i].x = next_int();
    a[i].y = next_int();
    a[i].z = i;
    a[i].numb = a[i].x / 1000;
  }
  sort(a, a + n, o1);
  for (int i = 0; i < n; i++) printf("%d ", a[i].z + 1);
}
