#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<complex>
#define mod 1000000007
#define lol(i,n) for(int i=0;i<n;i++)
using namespace std;
int dp[1<<16][15];
pair<int,int> from[1<<16][15];
int w[1<<16],n;
int s[15],d[15],v[15];
int main(){
  cin>>n;
  lol(i,n){
    cin>>s[i]>>d[i]>>v[i];
    lol(j,(1<<n)){
      dp[j][i]=mod;
    }
    dp[(1<<i)][i]=0;
  }
  w[0]=0;
  for(int k=0;k<(1<<n);k++){
    lol(last,n){
      lol(to,n){
	if(k%(1<<(to+1))>=(1<<to))continue;
	int tmp=dp[k][last]+abs(d[to]-d[last])*(7+2*w[k]);
	if(tmp<dp[k+(1<<to)][to]){
	  dp[k+(1<<to)][to]=tmp;
	  from[k+(1<<to)][to]=make_pair(k,last);
	}
	w[k+(1<<to)]=w[k]+v[to];
      }
    }
  }
  vector<int> v;
  pair<int,int> pnt;
  int mini=mod;
  lol(i,n){
    if(mini>dp[(1<<n)-1][i]){
      mini=dp[(1<<n)-1][i];
      pnt=make_pair((1<<n)-1,i);
    }
  }
  while(true){
    int a=pnt.first,b=pnt.second;
    v.push_back(s[b]);
    if(a==(1<<b))break;
    pnt=from[a][b];
  }
  lol(i,v.size()){
    if(i)cout<<" ";
    cout<<v[v.size()-1-i];
  }
  cout<<endl;
  return 0;
}