#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1000 * 1000 + 17, sq = 1000;   int n, a[MAXN];   vector<pair<int, int> > p;   bool cmp(int i, int j) {     i--, j--;     if (p[i].first / sq != p[j].first / sq) return p[i].first < p[j].first;     return ((p[i].first / sq) % 2 ? p[i].second > p[j].second                                   : p[i].second < p[j].second);   }   int main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     cin >> n;     for (int i = 1; i <= n; i++) {       int x, y;       cin >> x >> y;       p.push_back({x, y});     }     iota(a + 1, a + n + 1, 1);     sort(a + 1, a + n + 1, cmp);     for (int i = 1; i <= n; i++) cout << a[i] <<    ;     return 0;   }   