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

int N;
vector<int> id;
vector<int> weight;
vector<int> dist;

double cost(int from, int to, int bit) {
    double w = 0;
    for(int i = 0; i < N; i++) {
        if(bit & (1 << i)) w += weight[i];
    }
    return abs(dist[from] - dist[to]) / (2000 / (70 + w));
}

typedef pair<int, int> P;
typedef pair<double, vector<int> > PP;

const double INF = 1e9;

const int MAX_N = 15;
PP dp[MAX_N][1 << MAX_N];

/*
pair<double, vector<int> > tsp(int v, int b) {
    if(dp[v][b].first != -1) return dp[v][b];
    if(b == (1 << N) - 1) {
        PP res;
        res.first = 0;
        res.second.push_back(id[v]);
        return dp[v][b] = res;
    }

    PP res;
    res.first = 1e9;

    for(int i = 0; i < N; i++) {
        if(b & (1 << i)) continue;
        PP r = tsp(i, b | (1 << i));
        r.first += cost(v, i, b);
        if(r.first < res.first) {
            res = r;
        }
    }

    if(b != 0) res.second.insert(res.second.begin(), id[v]);
    return dp[v][b] = res;
}
*/

int main() {
    cin >> N;
    id.clear();
    weight.clear();
    dist.clear();
    for(int i = 0; i < N; i++) {
        int num, d, box;
        cin >> num >> d >> box;
        id.push_back(num);
        dist.push_back(d);
        weight.push_back(box * 20);
    }

    for(int v = 0; v < N; v++) {
        for(int s = 0; s < (1 << N); s++) {
            dp[v][s].first = INF;
            dp[v][s].second.clear();
        }
    }

    for(int v = 0; v < N; v++) {
        dp[v][(1 << N) - 1].first = 0;
    }

    for(int S = (1 << N) - 2; S >= 0; S--) {
        for(int v = 0; v < N; v++) {
            for(int u = 0; u < N; u++) {
                PP r = dp[u][S | (1 << u)];
                r.first += cost(v, u, S);
                r.second.push_back(id[u]);
                if(r.first < dp[v][S].first) {
                    dp[v][S] = r;
                }
            }
        }
    }

    PP res;
    res.first = INF;
    for(int i = 0; i < N; i++) {
        // PP r = tsp(i, 0);
        PP r = dp[i][0];
        if(r.first < res.first) {
            res = r;
        }
    }

    cout << *res.second.rbegin();
    for(int i = res.second.size() - 2; i >= 0; i--) {
        cout << ' ' << res.second[i];
    }
    cout << endl;
}