#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) {
    int 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;
map<P, pair<double, vector<int> > > memo;

pair<double, vector<int> > tsp(int v, int b) {
    if(memo.count(P(v, b))) return memo[P(v, b)];
    if(b == (1 << N) - 1) {
        vector<int> ord;
        ord.push_back(id[v]);
        return memo[P(v, b)] = pair<double, vector<int> >(0, ord);
    }

    vector<int> ord;
    double min_dist = 1e9;
    for(int i = 0; i < N; i++) {
        if(b & (1 << i)) continue;
        int S = b | (1 << i);
        pair<double, vector<int> > res = tsp(i, S);
        int D = res.first + cost(v, i, S);
        if(D < min_dist) {
            min_dist = D;
            ord = res.second;
        }
    }

    vector<int> res;
    if(b != 0) res.push_back(id[v]);
    for(int i = 0; i < (int)ord.size(); i++) res.push_back(ord[i]);
    return memo[P(v, b)] = pair<double, vector<int> >(min_dist, res);
}

int main() {
    cin >> N;
    id.clear();
    weight.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);
    }

    vector<int> order;
    double min_dist = 1e9;
    for(int i = 0; i < N; i++) {
        pair<double, vector<int> > res = tsp(i, 0);
        if(res.first < min_dist) {
            min_dist = res.first;
            order = res.second;
        }
    }
    cout << *order.begin();
    for(int i = 1; i < (int)order.size(); i++) {
        cout << ' ' << order[i];
    }
    cout << endl;
}