#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<map>
#include<stack>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<sstream>
 
 
#define reps(i,f,n) for(int i = f; i < int(n); i++)
#define rep(i,n) reps(i,0,n)
//typedef long long ll;

using namespace std;

const int INF = 1000000000;
const int N = 16;
const int MAX = 1<<N;

pair<double,int> dp[N][MAX];

int n;
int id[N];
int dis_c[N];
int weight[N];
int w[MAX];
int dist[N][N];


int main(void){
	
	int shift = 0;
	
	rep(i,N)rep(j,MAX)dp[i][j] = pair<double,int>(INF, INF);
	rep(i,N)rep(j,N)dist[i][j] = INF;
	rep(i,N)dist[i][i] = 0;
	
	scanf("%d", &n);
	
	rep(i,n){
		scanf("%d %d %d", &id[i], &dis_c[i], &weight[i]);
	}
	
	shift = 1<<n;
	
	rep(i,shift){
		int sum = 0;
		rep(j,n){
			if(i & 1<<j){
				sum += weight[j];
			}
		}
		w[i] = sum;
 	}
	
	rep(i,n)rep(j,n){
		dist[i][j] = dist[j][i] = abs(dis_c[i] - dis_c[j]);
	}
	
	rep(i,n)
		dp[i][1<<i] = pair<double,int>(0, -1);
	
	
	rep(i,shift){
		rep(j,n){
			if(i&(1<<j)){
				rep(k,n){
					if(!(i&(1<<k))){
						if(k==j)continue;
//						printf("dp[%d][%d].f = %lf, dist[%d][%d] = %d, w[%d] = %d\n", j,i,dp[j][i].first, k, i, dist[j][k], i, w[i]);
						if(dp[k][i|1<<k].first > dp[j][i].first + dist[j][k] * w[i]){
							dp[k][i|1<<k].first = dp[j][i].first + dist[j][k] * w[i];
							dp[k][i|1<<k].second = j;
						}
					}
				}
			}
		}
	}
	
	
	
	int ans = INF;
	int p = -1;
	int x = shift -1;
	rep(i,n){
		if(ans > dp[i][x].first){
			ans = dp[i][x].first;
			p = i;
		}
	}
	
	stack<int> s;
	
	while(p != -1 && x != 0){
		int n = dp[p][x].second;
		s.push(id[p]);
		x -= (1<<p);
		p = n;
	}
	
	while(!s.empty()){
		printf("%d", s.top());
		s.pop();
		if(!s.empty())printf(" ");
	}
	puts("");
	
	
	return 0;
}