#include <cstdio>
#include <algorithm>
#include <cmath>

#define EPS (0.0001)

using namespace std;

typedef struct {
	int no;
	int dist;
	int money;
} Store;

Store data[16];
double dp[1 << 16][16];
int n;

void print(int S, int v, int idx)
{
	printf("%d%c", data[v].no, idx == n - 1 ? '\n' : ' ');
	
	if (idx == n - 1) return;
	
	double m = -1;
	int nxt;
	for (int i = 0; i < n; i++){
		if (!((S >> i) & 1) && (m < 0 || dp[S | (1 << i)][i] < m)){
			nxt = i;
			m = dp[S | (1 << i)][i];
		}
	}
	
	print(S | (1 << nxt), nxt, idx + 1);
}

double getTime(int S, int v)
{
	int ans[16];
	if (~v && dp[S][v] >= 0){
		return (dp[S][v]);
	}
	
	if (S == (1 << n) - 1){
		return (dp[S][v] = 0);
	}
	
	int sumMoney = 0;
	for (int i = 0; i < n; i++){
		if ((S >> i) & 1) sumMoney += data[i].money;
	}
	
	int minNode;
	double minTime = -1;
	for (int i = 0; i < n; i++){
		if (!((S >> i) & 1)){
			int dx = abs((~v ? data[v].dist : 0) - data[i].dist);
			double nv = 2000.0 / (70 + 20 * sumMoney);
			double nowTime = dx / nv + getTime(S | (1 << i), i);
			if (minTime < 0) minTime = nowTime;
			else minTime = min(minTime, nowTime);
			if (minTime == nowTime){
				minNode = i;
			}
		}
	}
	if (~v){
		return (dp[S][v] = minTime);
	}
	else {
		print(1 << minNode, minNode, 0);
		return (minTime);
	}
}

int main()
{
	int route[16];
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++){
		scanf("%d %d %d", &data[i].no, &data[i].dist, &data[i].money);
	}
	
	for (int i = 0; i < 1 << 16; i++){
		for (int j = 0; j < 16; j++){
			dp[i][j] = -1;
		}
	}
	getTime(0, -1);
	
	return (0);
}