#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> bool chmin(T &a, const T &b){ return a > b && (a = b, true); }
template<class T> bool chmax(T &a, const T &b){ return a < b && (a = b, true); }

int main() {
    int n;
    cin >> n;
    vector<int> s(n), d(n), v(n);
    for (int i = 0; i < n; ++i) {
        scanf("%d %d %d", &s[i], &d[i], &v[i]);
    }
    vector<int> S(1 << n, 7);
    for (int i = 0; i < 1 << n; ++i) {
        for (int j = 0; j < n; ++j) {
            if(i & (1 << j)) S[i] += 2*v[j];
        }
    }
    auto dp = make_v(n, 1 << n, INF<ll>);
    auto prv = make_v(n, 1 << n, 0);
    for (int i = 0; i < n; ++i) {
        dp[i][1 << i] = 0;
    }
    for (int j = 0; j < 1 << n; ++j) {
        for (int i = 0; i < n; ++i) {
            if(dp[i][j] == INF<ll>) continue;
            for (int k = 0; k < n; ++k) {
                if(!(j & (1 << k))) {
                    if(chmin(dp[k][j^(1 << k)], dp[i][j]+S[j]*abs(d[i]-d[k]))){
                        prv[k][j^(1 << k)] = i;
                    }
                }
            }
        }
    }
    stack<int> ans;
    int b = 0, a = (1 << n)-1;
    for (int i = 0; i < n; ++i) if(dp[i][a] < dp[b][a]) b = i;
    while(a){
        ans.emplace(b);
        int x = prv[b][a];
        a -= 1 << b; b = x;
    }
    while(!ans.empty()){
        printf("%d", s[ans.top()]);
        ans.pop();
        if(!ans.empty()) printf(" ");
    }
    puts("");
    return 0;
}
