#include<iostream>
#include<queue>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair
#define INF 1<<30
using namespace std;
int main(){
	//ツ渉可甘コツ可サ
	int n; cin>>n;
	int id[n],d[n],a[n],prev[1<<n][n],w[1<<n],ans[n];
	rep(i,n)cin>>id[i]>>d[i]>>a[i];
	rep(i,1<<n){
		w[i]=0; rep(j,n)w[i]+=i&(1<<j)?2*a[j]:0;
	}
	int t[1<<n][n],mn=INF,mni; rep(i,1<<n)rep(j,n)t[i][j]=INF;
	//TSP
	queue<pair<int,int> > F;
	rep(i,n)F.push(mp(1<<i,i)),t[1<<i][i]=0;
	while(!F.empty()){
		int s=F.front().first,c=F.front().second,ns; F.pop();
		rep(i,n)if(!((1<<i)&s)){
			ns=s|(1<<i); int tt=t[s][c]+(d[i]>d[c]?d[i]-d[c]:d[c]-d[i])*(7+w[s]);
			if(t[ns][i]>tt)F.push(mp(ns,i)),t[ns][i]=tt,prev[ns][i]=c;
		}
	}
	rep(i,n)if(mn>t[(1<<n)-1][i])mn=t[(1<<n)-1][i],mni=i;
	ans[0]=mni;
	for(int i=1,s=(1<<n)-1;i<n;i++)ans[i]=prev[s][ans[i-1]],s^=1<<ans[i-1];
	rep(i,n)cout<<id[ans[n-i-1]]<<(i<n-1?" ":"\n");
	return 0;
}