#include<stdio.h>
#include<stdlib.h>
#define INF 100000000
int num[15];
int d[15];
int w[15];
double dp[15][1<<15];
int bfr[15][1<<15];
int n;
double dfs(int used,int pos,int weight){
	if(used==(1<<n)-1)return 0;
	if(dp[pos][used]!=-1)return dp[pos][used];
	int i;
	double res=INF;
	for(i=0;i<n;i++){
		if(!((used>>i)&1)){
			double p=0;
			if(used!=0)p=(double)abs(d[i]-d[pos])/2000*(70+weight);
			double next=dfs(used|1<<i,i,weight+w[i])+p;
			if(next<res){
				res=next;
				bfr[pos][used]=i;
			}
		}
	}
	return dp[pos][used]=res;
}
int main(){
	scanf("%d",&n);
	int i,j;
	for(i=0;i<1<<n;i++)for(j=0;j<n;j++)dp[j][i]=-1;
	for(i=0;i<n;i++)bfr[i][(1<<n)-1]=-1;
	for(i=0;i<n;i++){
		scanf("%d %d %d",&num[i],&d[i],&w[i]);
		w[i]*=20;
	}
	double ans=INF;
	dfs(0,0,0);
	int p=0;
	int used=0;
	while(bfr[p][used]!=-1){
		int next=bfr[p][used];
		printf("%d",num[next]);
		used|=1<<next;
		p=next;
		if(bfr[p][used]!=-1)printf(" ");
	}
	printf("\n");
	return 0;
}