#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

const int MaxN = 5e3 + 35;

struct point
{
  int x, y, idx;
  point( int _x, int _y, int _idx )
  {
    x = _x;
    y = _y;
    idx = _idx;
  }
  bool operator < ( const point &A ) const
  {
    if ( x != A.x ) return x < A.x;
    if ( y != A.y ) return y < A.y;
    return idx < A.idx;
  }
};

int n, x, y, curr;
bool mark[ MaxN ];
vector< point > niz;

int main()
{
  freopen( "flojd.in", "r", stdin );
  freopen( "flojd.out", "w", stdout );
  scanf( "%d", &n );
  for ( int i = 0; i < n; i++ )
  {
    scanf( "%d %d", &x, &y );
    niz.push_back( point( x, y, i + 1 ) );
  }
  if ( n == 3 )
  {
    printf( "1\n2\n3\n" );
    return 0;
  }
  sort( niz.begin(), niz.end() );
  for ( int brojac = 0, smer = 0; brojac < n; brojac++, smer ^= 1 )
  {
    mark[ curr ] = true;
    printf( "%d\n", niz[ curr ].idx );
    for ( int i = 0; i < n; i++ ) if ( !mark[ i ] )
    {
      if ( smer ^ ( niz[ i ].y > niz[ curr ].y ) )
      {
        curr = i;
        break;
      }
    }
  }
  return 0;
}
