#include <iostream>
#include <algorithm>
#include <cstdlib>
using namespace std;

const int MAX_N = 15;
int N;
int No[MAX_N], Dist[MAX_N], Sen[MAX_N];
int G[1<<MAX_N][MAX_N][MAX_N];
int T[1<<MAX_N][MAX_N], path[1<<MAX_N][MAX_N];

const int INF = 1<<24;

int calcW(int s) {
  int w = 0;
  for(int i = 0; i < N; ++i) {
    if(s & (1<<i)) w += 2*Sen[i];
  }
  return w;
}

void make() {
  for(int s = 0; s < (1<<N); ++s) {
    for(int i=0;i<N;++i){
      for(int j=0;j<N;++j){
	if(i == j) G[s][i][j] = INF;
	else G[s][i][j] = abs(Dist[i]-Dist[j])*(7+calcW(s));
      }
    }
  }
}

void rec(int s, int p) {
  if(s == (1<<p)){
    cout << No[p];
    return;
  }
  rec(s&~(1<<p), path[s][p]);
  cout << " " << No[p];
}

void solve() {
  make();
  for(int i=0;i<(1<<N);++i)
    fill(T[i],T[i]+N,INF);
  for(int i = 0; i < N; ++i)
    T[1<<i][i] = 0;

  for(int s = 1; s < (1<<N); ++s) {
    for(int i = 0; i < N; ++i) {
      if(!(s&(1<<i))) continue;
      for(int j = 0; j < N; ++j) {
	if(s&(1<<j)) continue;
	int newValue = T[s][i] + G[s][i][j];
	if(newValue < T[s|(1<<j)][j]) {
	  T[s|(1<<j)][j] = newValue;
	  path[s|(1<<j)][j] = i;
	}
      }
    }
  }

  int mini, mi;
  mini = INF, mi = -1;
  for(int i = 0; i < N; ++i) {
    if(T[(1<<N)-1][i] < mini) {
      mini = T[(1<<N)-1][i];
      mi = i;
    }
  }
  rec((1<<N)-1, mi);
}

int main() {
  cin >> N;
  for(int i=0;i<N;++i)cin >>No[i]>>Dist[i]>>Sen[i];
  solve();
  return 0;
}