#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const double dINF = 1e30;

double myabs(double a) {
    return a > 0 ? a : -a;
}

int main() {
    int N;
    cin >> N;
    std::vector<int> b;
    std::vector<int> p;
    std::vector<int> w;
    for (int i = 0; i < N; ++i) {
        int temp1, temp2, temp3;
        cin >> temp1 >> temp2 >> temp3;
        b.push_back(temp1);
        p.push_back(temp2);
        w.push_back(temp3 * 20);
    }

    vector<vector<double> > dp(1 << N, vector<double>(N, dINF));
    vector<vector<int> > dp_i(1 << N, vector<int>(N, 0));
    vector<vector<int> > dp_j(1 << N, vector<int>(N, 0));

    for(int i = 0; i < N; i++) {
        dp[1 << i][i] = 0;
    }

    for (int i = 1; i < 1 << N; ++i) {
        double sumw = 0;
        for (int j = 0; j < N; ++j) {
            if (i >> j & 1) {
                sumw += w[j];
            }
        }

        for (int j = 0; j < N; ++j) {
            if (!(i >> j & 1)) continue;
            for (int k = 0; k < N; ++k) {
                if (i >> k & 1) continue;
                double dist = ((70 + sumw) * myabs(p[j] - p[k]) / 2000);
                if (dp[i | (1 << k)][k] > dp[i][j] + dist) {
                    dp[i | (1 << k)][k] = dp[i][j] + dist;
                    dp_i[i | (1 << k)][k] = i;
                    dp_j[i | (1 << k)][k] = j;
                }
            }
        }
    }

    double min_dist = dINF;
    int min_j;
    for(int j = 0; j < N; j++) {
        if (dp[(1 << N) - 1][j] < min_dist) {
            min_dist = dp[(1 << N) - 1][j];
            min_j = j;
        }
    }

    int min_i = (1 << N) - 1;
    std::vector<int> ans_j;
    for (int i = 0; i < N; ++i) {
        ans_j.push_back(min_j);
        int min_i_next = dp_i[min_i][min_j];
        int min_j_next = dp_j[min_i][min_j];
        min_i = min_i_next;
        min_j = min_j_next;
    }

    std::reverse(ans_j.begin(), ans_j.end());

    for (int i = 0; i < N; ++i)
    {
        cout << b[ans_j[i]] << " ";
    }
    cout << endl;


    return 0;
}