#include <stdio.h>
#include <stdlib.h>

double time(int a,int b,int m){
	double sub;
	sub = a - b;
	if(sub < 0)
		sub *= - 1;
	return (sub * (70 + m)) / 2000;
}

double dp[15][15];
int *num, *dist, *money, *p, *fp;

void MRS(int j,int count,int n,double t,int m,double *first){
	int i, k, flag;
	double tmp;
	if(count == 1){
		for(i = 0;i < n;i++){
			for(j = 0;j < n;j++)
				dp[i][j] = 1.7E308;
		}
	}
	if(count < n){
		for(i = (j + 1) % n;i != j;i = (i + 1) % n){
			flag = 0;
			for(k = 0;k < count;k++){
				if(*(num + i) == *(p + k))
					flag = 1;
			}
			if(flag == 0){
				for(k = 0;*(num + k) != *(p + count - 1);k++);
				tmp = time(*(dist + k),*(dist + i),m);
				if(dp[count][i] > t + tmp){
					dp[count][i] = t + tmp;
					*(p + count) = *(num + i);
					m += *(money + i) * 20;
					count++;
					MRS(i,count,n,t + tmp,m,first);
					count--;
					*(p + count) = 0;
					m -= *(money + i) * 20;
				}
				else
					return;
			}
		}
	}
	else if(count == n){
		if(*first == -1){
			*first = t;
			for(i = 0;i < n;i++)
				*(fp + i) = *(p + i);
		}
		else if(*first > t){
			*first = t;
			for(i = 0;i < n;i++)
				*(fp + i) = *(p + i);
		}
	}
	return;
}
int main(void){
	int i, n;
	double *first;
	first = (double *)malloc(sizeof(double));
	*first = -1;
	scanf("%d",&n);
	num = (int *)malloc(sizeof(int) * n);
	dist = (int *)malloc(sizeof(int) * n);
	money = (int *)malloc(sizeof(int) * n);
	p = (int *)malloc(sizeof(int) * n);
	fp = (int *)malloc(sizeof(int) * n);
	for(i = 0;i < n;i++)
		scanf("%d%d%d",num + i,dist + i,money + i);
	for(i = 0;i < n;i++){
		*(p + 0) = *(num + i);
		MRS(i,1,n,0,*(money + i) * 20,first);/*MRS(j,count,n,t,m,first)*/
	}
	for(i = 0;i < n;i++)
		printf("%d ",*(fp + i));
	printf("\n");
	return 0;
}