#include<iostream>
#include<bitset>
#include<vector>

#define INV (-1)
#define INFTY 2000000000
#define UNIT 20
#define MAX 15
#define ST_MAX 32756

using namespace std;

int ids[MAX];
int weights[MAX];
int distances[MAX][MAX];
double A[ST_MAX];
int a[ST_MAX];

inline double V(int n)
{
	return (double)2000 / (70 + n * UNIT);
}
double W(int from, int to, bitset<MAX> &b)
{
	int w = 0;
	for(int i = 0; i < MAX; ++i)
	{
		w += (b[i] ? weights[i] : 0);
	}
	return distances[from][to] / V( w );
}
void comb_compute(int n, int k)
{
	int *p;
	bool loop = false;
	p = new int[k];for(int i = 0; i < k; i++) p[i] = i;	
	do{

		bitset<MAX> b;
		loop = false;
		
		for(int i = 0; i < k; ++i) b.set(p[i]);
		
		int min_ind = INV;
		double min_t = INFTY;
		for(int i = 0; i < k; ++i)
		{
			double t;
			b.reset( p[i] );
			t = A[b.to_ulong()] + W(a[b.to_ulong()], p[i], b);
			if( t < min_t )
			{
				min_t = t;
				min_ind = p[i];
			}
			b.set( p[i] );
		}
		A[b.to_ulong()] = min_t;
		a[b.to_ulong()] = min_ind;

	for(int pk=k-1;pk>=0;pk--){p[pk]++;if(p[pk]<=n-(k-pk)){for(int j=pk+1;j<k;j++)p[j]=p[j-1]+1;pk++;loop=true;break;}}
	}while(loop);delete [] p;
}
void compute(int n)
{
	unsigned long l = 1;

	for(int i = 0; i < ST_MAX; ++i)
	{
		A[i] = INFTY;
		a[i] = INV;
	}
	
	A[0] = 0;
	a[0] = INV;

	for(int i = 0; i < n; ++i)
	{
		A[l] = 0;
		a[l] = i;
		l <<= 1;
	}

	for(int k = 2; k <= n; ++k)
	{
		comb_compute(n, k);
	}
}

int main()
{
	int n;
	int dist[MAX];

	cin >> n;

	for(int i = 0; i < n; ++i)
	{
		int id, d, w;
		cin >> id >> d >> w;
		ids[i] = id;
		dist[i] = d;
		weights[i] = w;
	}
	
	for(int i = 0; i < n; ++i)
		for(int j = 0; j < n; ++j)
			distances[i][j] = abs( dist[i] - dist[j] );

	compute( n );

	bitset<MAX> bMax((1<<n)-1);
	int goal = a[(1<<n)-1];

	cout << ids[goal];
	bMax.reset( goal );
	while( bMax.to_ulong() > 0 )
	{
		goal = a[bMax.to_ulong()];
		bMax.reset(goal);
		cout << ' ' << ids[goal];
	}
	cout << '\n';
	return 0;
}