#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int INF = 1 << 30;
int n;
int s[15], d[15], v[15];
int dp[1 << 15][15];
int pre[1 << 15][15];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s[i] >> d[i] >> v[i];
  }
  fill_n((int*)dp, (1 << 15) * 15, INF);
  for (int i = 0; i < n; i++) {
    dp[1 << i][i] = d[i];
    pre[1 << i][i] = -1;
  }
  for (int mask = 0; mask < 1 << n; mask++) {
    int sum = 0;
    for (int i = 0; i < n; i++) {
      if (mask >> i & 1) sum += v[i];
    }
    for (int i = 0; i < n; i++) {
      if (!(mask >> i & 1)) continue;
      for (int j = 0; j < n; j++) {
        if (mask >> j & 1) continue;
        int nmask = mask + (1 << j), cost = sum * abs(d[j] - d[i]);
        if (dp[nmask][j] > dp[mask][i] + cost) {
          dp[nmask][j] = dp[mask][i] + cost;
          pre[nmask][j] = i;
        }
      }
    }
  }
  int mask = (1 << n) - 1, last = 0;
  for (int i = 0; i < n; i++) {
    if (dp[mask][i] < dp[mask][last]) last = i;
  }
  vector<int> ans;
  while (last >= 0) {
    ans.emplace_back(last);
    int tmp = last;
    last = pre[mask][last];
    mask -= 1 << tmp;
  }
  reverse(ans.begin(), ans.end());
  for (int i = 0; i < int(ans.size()); i++) {
    cout << s[ans[i]] << " \n"[i + 1 == int(ans.size())];
  }

  return 0;
}
