#include <bits/stdc++.h>
using namespace std;
int read() {
  char x = getchar();
  int u = 0, fg = 0;
  while (!isdigit(x)) {
    if (x == '-') fg = 1;
    x = getchar();
  }
  while (isdigit(x)) {
    u = (u << 3) + (u << 1) + (x ^ 48);
    x = getchar();
  }
  return fg ? -u : u;
}
const int maxx = 1e6 + 10;
int n;
struct node {
  int x, y, id, posx, posy;
} a[maxx];
bool cmp(node A, node B) {
  if (A.posx == B.posx && A.posy == B.posy) {
    return A.x + A.y < B.x + B.y;
  }
  if (A.posx == B.posx) {
    if (A.posx & 1)
      return A.posy > B.posy;
    else
      return A.posy < B.posy;
  }
  return A.posx < B.posx;
}
int main() {
  n = read();
  for (register int i = (1); i <= (n); ++i) {
    a[i].x = read();
    a[i].y = read();
    a[i].id = i;
    a[i].posx = a[i].x / 1000;
    a[i].posy = a[i].y / 1000;
  }
  sort(a + 1, a + n + 1, cmp);
  for (register int i = (1); i <= (n); ++i) printf("%d ", a[i].id);
  return 0;
}
