#include <iostream>
#include <vector>
#include <limits>
#include <algorithm>
using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<int> dists(N), ids(N), cnts(N);
  for (int i = 0; i < N; i++) {
    int id, dist, c;
    cin >> id >> dist >> c;
    dists[i] = dist;
    cnts[i] = 20*c;
    ids[i] = id;
  }

  vector<int> ws(1<<N, 0);
  for (int s = 0; s < (1<<N); s++) {
    for (int i = 0; i < N; i++) {
      if (s & (1<<i)) {
        ws[s] += cnts[i];
      }
    }
  }

  vector<vector<int> > prev(1<<N, vector<int>(N));
  vector<vector<double> > dp(1<<N, vector<double>(N, numeric_limits<double>::max()));
  for (int i = 0; i < N; i++) {
    dp[1<<i][i] = 0;
    prev[1<<i][i] = -1;
  }
  for (int s = 0; s < (1<<N); s++) {
    const double v = 2000.0/(70.0+ws[s]);
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        if (!(s & (1<<i)) || s & (1<<j)) {
          continue;
        }
        const double t = dp[s][i] + abs(dists[i]- dists[j]) / v;
        if (dp[s|(1<<j)][j] > t) {
          dp[s|(1<<j)][j] = t;
          prev[s|(1<<j)][j] = i;
        }
      }
    }
  }

  int last = -1;
  double m = numeric_limits<double>::max();
  for (int i = 0; i < N; i++) {
    if (dp[(1<<N)-1][i] < m) {
      m = dp[(1<<N)-1][i];
      last = i;
    }
  }

  vector<int> ans;
  for (int s = (1<<N)-1, i = last; i >= 0;) {
    ans.push_back(i);
    const int j = prev[s][i];
    s &= ~(1<<i);
    i = j;
  }
  reverse(ans.begin(), ans.end());
  for (int i = 0; i < N; i++) {
    if (i != 0) {
      cout << ' ';
    }
    cout << ids[ans[i]];
  }
  cout << endl;
  return 0;
}