#include <bits/stdc++.h>

#define reps(v, f, l) for (int v = (f), v##_ = (l); v < v##_; ++v)
#define rep(v, n) reps(v, 0, n)
#define lep(v, n) reps(v, 1, n + 1)

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }
template<typename T> void show(T& a, char del='\n', char last='\n'){ rep(i, a.size() - 1) cout << a[i] << del; cout << a[a.size() - 1] << last; }

struct Info {
  int weight;
  int time;
  int from;
  Info() : time(-1) {}
  Info(int w, int t, int f) : weight(w), time(t), from(f) {}
};

Info dp[1 << 16][16];
int main()
{
  int n = in();
  vector<int> ids;
  vector<int> dist;
  vector<int> weight;

  rep(i, n){
    ids.push_back(in());
    dist.push_back(in());
    weight.push_back(in());
  }
  rep(i, n){
    dp[1 << i][i] = Info(weight[i], 0, -1);
  }
  rep(state, 1 << n){
    rep(last, n){
      Info& src = dp[state][last];
      if (src.time == -1) continue;
      rep(next, n){
        if (state & (1 << next)) continue;
        Info& dst = dp[state | (1 << next)][next];
        int t = src.time + abs(dist[last] - dist[next]) * src.weight;
        if (dst.time == -1 || dst.time > t){
          dst = Info(src.weight + weight[next], t, last);
        }
      }
    }
  }
  int id = 0;
  int state = (1 << n) - 1;
  Info& best = dp[state][id];
  rep(i, n){
    if (best.time > dp[state][i].time){
      best = dp[(1 << n) - 1][i];
      id = i;
    }
  }
  vector<int> ans;
  while (1){
    ans.push_back(ids[id]);
    if (best.from == -1) break;
    state &= ~(1 << id);
    id = best.from;
    best = dp[state][id];
  }
  reverse(ans.begin(), ans.end());
  show(ans, ' ');
  return 0;
}