/*
    Marko Bakovic
    Flojd
*/

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

using namespace std;

const int maxn = 5e3 + 5;

struct dot
{
    int x, y, idx;
    bool operator < ( const dot & newD ) const
    {
        return x < newD.x;
    }
} point[ maxn ];

int n;

bool found, mark[ maxn ];

vector < int > sol;

void dfs( int idx, bool up )
{
    mark[ idx ] = true;
    sol.push_back( idx );
    if ( sol.size() == n )
    {
        found = true;
        return;
    }
    for ( int i = 0; i < n; i++ )
        if ( ! mark[ i ] )
        {
            if ( up && point[ i ].y > point[ idx ].y ) dfs( i, ! up );
            else if ( ! up && point[ i ].y < point[ idx ].y ) dfs( i, ! up );
            if ( found ) return;
        }
    if ( found ) return;
    sol.pop_back();
    mark[ idx ] = false;
}

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", &point[ i ].x, &point[ i ].y );
        point[ i ].idx = i + 1;
    }

    sort( point, point + n );

    found = false;
    for ( int i = 0; i < n; i++ )
    {
        dfs( i, true );
        if ( found )
        {
            for ( int i = 0; i < sol.size(); i++ ) printf( "%d\n", point[ sol[ i ] ].idx );
            break;
        }
    }

    return 0;
}
