#include<iostream>
#include<stack>
#include<algorithm>
#include<utility>

struct Node {
	int number, distance, weight;
	Node() = default;
	Node(int _n, int _d, int _w) : number(_n),
		distance(_d), weight(_w) {}
};

constexpr int MAX_N = 15;

using P = std::pair<double, std::stack<int>>;

int n;
Node nodes[MAX_N];
P memo[MAX_N][(1 << MAX_N)];

std::stack<int> stk;
P res, ans;

P solve(int x, int S,int w) {
	if (S == (1 << n) - 1) {
		if (!stk.empty())
			stk.pop();
		stk.push(nodes[x].number);
		return P(0, stk);
	}
	if (memo[x][S].first > 0)
		return memo[x][S];

	ans.first = 1e9;
	for (int i = 0; i < n; ++i) {
		if (!((S >> i) & 1)) {
			res = solve(i, S | (1 << i), w + nodes[x].weight);
			res.first += abs(nodes[i].distance - nodes[x].distance)*(70 + w + nodes[x].weight) / 2000;
			if (ans.first > res.first)
				ans = std::move(res);
		}
	}
	ans.second.push(nodes[x].number);
	return memo[x][S] = ans;
}

int main() {
	std::cin >> n;
	int w;
	for (int i = 0; i < n; ++i) {
		std::cin >> nodes[i].number >> nodes[i].distance >> w;
		nodes[i].weight = w * 20;
	}
	P ans = P(1e9, std::stack<int>()), res;
	for (int i = 0; i < n; ++i) {
		res = solve(i, (1 << i), 0);
		if (ans > res)
			ans = std::move(res);
	}
	std::cout << ans.second.top();
	ans.second.pop();
	while (!ans.second.empty()) {
		std::cout << ' ' << ans.second.top();
		ans.second.pop();
	}
	std::cout << std::endl;
	return 0;
}