#include <bits/stdc++.h>
using namespace std;
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;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &a[i].x, &a[i].y);
    a[i].z = i;
    a[i].numb = a[i].x / 1000;
  }
  sort(a, a + n, o1);
  for (int i = 0; i < n; i++) cout << a[i].z + 1 << " ";
}
