#include <vector>
#include <iostream>
using namespace std;
struct state {
	vector<int> v;
	long long cost;
};
int n, id[19], p[19], w[19], sum[32777], popcount[32777]; state dp[19][32777];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> id[i] >> p[i] >> w[i];
	}
	for (int i = 0; i < n; i++) {
		for (int j = 1 << i; j < 2 << i; j++) {
			sum[j] = sum[j - (1 << i)] + w[i] * 20;
			popcount[j] = popcount[j - (1 << i)] + 1;
		}
	}
	for (int i = 0; i < n; i++) dp[i][1 << i] = state({ vector<int>({i}), 0 });
	for (int i = 1; i < 1 << n; i++) {
		if (popcount[i] == 1) continue;
		for (int j = 0; j < n; j++) {
			if (!(i & (1 << j))) continue;
			dp[j][i].cost = 1LL << 60;
			int sub = i - (1 << j);
			for (int k = 0; k < n; k++) {
				if (!(sub & (1 << k))) continue;
				long long cost = dp[k][sub].cost + 1LL * (70 + sum[sub]) * abs(p[j] - p[k]);
				if (dp[j][i].cost > cost) {
					dp[j][i].cost = cost;
					dp[j][i].v = dp[k][sub].v;
					dp[j][i].v.push_back(j);
				}
			}
		}
	}
	int pos = 0;
	for (int i = 1; i < n; i++) {
		if (dp[i][(1 << n) - 1].cost < dp[pos][(1 << n) - 1].cost) {
			pos = i;
		}
	}
	vector<int> ret = dp[pos][(1 << n) - 1].v;
	for (int i = 0; i < n; i++) {
		if (i) cout << ' ';
		cout << id[ret[i]];
	}
	cout << endl;
	return 0;
}