#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)c.size())

typedef unsigned long long ull;
const int INF = (int)1e8;

int n;
int id[15],m[15],w[15];

int main(){
	cin>>n; FOR(i,n) cin>>id[i]>>m[i]>>w[i];
	
	vector<int> v(n);
	FOR(i,n) v[i] = i;
	double ans = 1e300;
	vector<int> ans_v;
	do{
		int c_w = 0;
		double c_t = 0;
		int c_m = 0;
		FOR(i,n){
			c_t = abs(m[v[i]] - c_m) / (2000.0 / (70 + c_w));
			c_m = m[v[i]];
			c_w += w[v[i]];
		}
		if(ans > c_t){
			ans = c_t;
			ans_v.clear();
			copy(v.begin(),v.end(),back_inserter(ans_v));
		}
	}while(next_permutation(v.begin(),v.end()));

	FOR(i,n){
		printf("%d%c",id[ans_v[i]],i==n-1?'\n':' ');
	}

	return 0;
}