#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <cmath>
using namespace std;

int id[20],dist[20],cnt[20];
double dp[1<<15][15];
pair<int,int> prev[1<<15][15];

int W[1<<15];


int main(){
	int n;
	while(cin >> n && n){
		for(int i = 0 ; i < n ; i++){
			cin >> id[i] >> dist[i] >> cnt[i];
		}
		for(int i = 0 ; i < (1<<15) ; i++)
			for(int j = 0 ; j < 15 ; j++)
				dp[i][j] = 1e12;
		for(int i = 0 ; i < n ; i++)
			dp[0][i] = 0;
		for(int i = 0 ; i < (1<<n) ; i++){
			int aaa = 0;
			for(int j = 0 ; j < n ; j++)
				if(i>>j&1) aaa += cnt[j];
			W[i] = aaa;
		}
		for(int i = 0 ; i < (1<<n) ; i++){
			for(int j = 0 ; j < n ; j++){
				for(int k = 0 ; k < n ; k++){
					double cost = abs(dist[j]-dist[k]) / ( 2000.0 / (70+20*W[i]) )+dp[i][j];
					if( dp[i|(1<<k)][k] > cost + 1e-9 ){
						prev[i|(1<<k)][k] = make_pair(i,j);
						dp[i|(1<<k)][k] = cost;
					}
				}
		
			}
		}
		double minCost = 1e12;
		for(int i = 0 ; i < n ; i++){
			minCost = min( dp[(1<<n)-1][i] , minCost) ;
		}
		for(int i = 0 ; i < n ; i++){
			if( fabs(minCost - dp[(1<<n)-1][i]) < 1e-9){
				int bit = (1<<n)-1;
				int k = i;
				vector<int> idd;
				while(bit){
					idd.push_back(k);
					pair<int,int> tmp = prev[bit][k];
					bit = tmp.first;
					k = tmp.second;
				}
				reverse(idd.begin(),idd.end());
				for(int j = 0 ; j < n ; j++)
					cout << id[idd[j]] << (char)(j==n-1?10:32);
			}
		}
	}	
}