#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
struct Warehouse {
	int id, position, count;
};
long long int min_cost(const int state, const int current, const long long int weight, const std::vector<Warehouse>& warehouses, std::vector<std::vector<long long int>>& memo) {
	if (state == memo.size() - 1) return 0;
	if (memo[state][current] >= 0) return memo[state][current];
	long long int min_time = LLONG_MAX;
	for (auto i = 0; i < warehouses.size(); ++i) if ((state & (1 << i)) == 0) {
		min_time = std::min(min_time, min_cost(state | (1 << i), i, weight + warehouses[i].count * 20, warehouses, memo) + std::abs(warehouses[current].position - warehouses[i].position) * weight);
	}
	return memo[state][current] = min_time;
}
std::vector<int> cal_min_route(const std::vector<Warehouse>& warehouse) {
	std::vector<std::vector<long long int>> memo(1 << warehouse.size(), std::vector<long long int>(warehouse.size(), -1));
	std::vector<int> result; result.reserve(warehouse.size());
	int state = 0;
	long long int default_weight = 70;
	int current_pos = 0;
	for (auto _i = 0; _i < warehouse.size(); ++_i) {
		long long int min = LLONG_MAX;
		int min_pos = 0;
		for (auto i = 0; i < warehouse.size(); ++i) if ((state & (1 << i)) == 0) {
			const auto temp = min_cost(state | (1 << i), i, default_weight + warehouse[i].count * 20, warehouse, memo) + (result.empty() ? 0.0 : (std::abs(current_pos - warehouse[i].position) * default_weight));
			if (min > temp) {
				min = temp;
				min_pos = i;
			}
		}
		result.push_back(warehouse[min_pos].id);
		state |= 1 << min_pos;
		default_weight += warehouse[min_pos].count * 20;
		current_pos = warehouse[min_pos].position;
	}
	return result;
}
int main() {
	int n; std::cin >> n;
	std::vector<Warehouse> warehourse(n); for (auto& w : warehourse) std::cin >> w.id >> w.position >> w.count;
	auto result = cal_min_route(warehourse);
	for (auto i = 0; i < n; ++i) {
		if (i != 0) std::cout << ' ';
		std::cout << result[i];
	}
	std::cout << '\n';
}
