#define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>
#include <ctime>

using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF = 1 << 30;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;
const int CLK = CLOCKS_PER_SEC;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)

int id[16];
int dis[16];
int w[16];
ll tw[1 << 16];
ll g[16][16];
ll memo[16][1 << 16];
int pv[16][1 << 16];

int main(){
	int n;
	cin >> n;
	rep(i, n){
		cin >> id[i] >> dis[i] >> w[i];
		w[i] *= 20;
	}
	
	fill(&memo[0][0], &memo[15][(1 << 16) - 1] + 1, 1LL << 50);
	memset(pv, -1, sizeof(pv));
	memset(tw, 0, sizeof(tw));

	rep(i, n)rep(j, n) g[i][j] = abs(dis[i] - dis[j]);
	rep(i, 1 << n){
		rep(j, n) if(i & (1 << j)) tw[i] += w[j];
	}

	rep(i, n) memo[i][1 << i] = tw[1 << i];

	rep2(s, 0, 1 << n){
		rep(i, n){
			if(s & (1 << i)){
				rep(j, n) {
					if(!(s & (1 << j))){
						ll cost = memo[i][s] + (70 + tw[s]) * g[i][j];
						if(cost < memo[j][s | (1 << j)]){
							memo[j][s | (1 << j)] = cost;
							pv[j][s | (1 << j)] = i;
						}
					}
				}
			}
		}
	}
	int p = 0;
	int s = (1 << n) - 1;
	ll best = 1LL << 50;
	rep(i, n) if(memo[i][(1 << n) - 1] < best){
		best = memo[i][(1 << n) - 1];
		p = i;
	}
	vector<int> res;
	res.push_back(id[p]);
	while(pv[p][s] != -1){
		int t = p;
		p = pv[p][s];
		s -= (1 << t);
		res.push_back(id[p]);
	}
	rep(i, (int)res.size()){
		if(i != 0) cout << " ";
		cout << res[(int)res.size() - i - 1];
	}
	cout << endl;
	return 0;
}