#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

class KuraInfo{
public:
	int num;
	int dist;
	int weight;
};

double dp[(1<<15)][15];
int dp2[(1<<15)][15];

int n;
KuraInfo kuras[15];
const int INF=100000000;

int best;

double dfs(const int s,const int d,const double sumWeight,const int depth){
	if(s==0)
		return 0;
	double minCost=INF;
	if(d==-1){
		for(int i = 0; i < n; i++){
			if(((s>>i)&1)){
				double ret = dfs((s&~(1<<i)),i,sumWeight+kuras[i].weight,depth+1);
				if(minCost>ret){
					best=i;
					minCost=min(minCost,ret);
				}
			}
		}
	}
	else{
		if(dp[s][d]!=INF)
			return dp[s][d];
		for(int i = 0; i < n; i++){
			if(((s>>i)&1)){
				double ret = dfs((s&~(1<<i)),i,sumWeight+kuras[i].weight,depth+1)
					+(
					((double)abs(kuras[i].dist-kuras[d].dist))
					/(((double)2000)/(70+sumWeight)));
				if(minCost>ret){
					dp2[s][d]=i;
					minCost=min(minCost,ret);
				}
			}
		}

	}
	dp[s][d]=minCost;
	return dp[s][d];
}

int main(){

	while(cin>>n){
		for(int i = 0; i < n; i++){
			cin>>kuras[i].num>>kuras[i].dist>>kuras[i].weight;
			kuras[i].weight*=20;
		}
		for(int i = 0; i < (1<<15); i++){
			fill(dp[i],dp[i]+15,INF);
			fill(dp2[i],dp2[i]+(15),INF);
		}
		
		dfs((1<<n)-1,-1,0,0);
		
		int s = (1<<n)-1;
		bool first=true;
		int prv;
		while(1){
			if(first){
				cout<<kuras[best].num;
				s=(s&~(1<<best));
				first=false;
				prv=best;
			}
			else{
				if(s==0){
					cout<<endl;
					break;
				}
				else
					cout<<" ";
				cout<<kuras[dp2[s][prv]].num;
				int np=dp2[s][prv];
				s=(s&~(1<<dp2[s][prv]));
				prv=np;
			}
		}
	}

	return 0;
}