#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#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 <cstring>
#include <sstream>
#include <cassert>
#include <list>
#include <ctime>
#include <numeric>
#include <fstream>
#include <valarray>
using namespace std;
static const double EPS = 1e-6;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int(a.size()))
#define F first
#define S second
const long double pi=acos(-1.0);
int dx[]={0,1,0,-1,1,1,-1,-1,0},dy[]={1,0,-1,0,1,-1,1,-1,0};


vector<int> ans;
int num[15];
int dist[15];
int sen[15];
int n;

double dp[1<<15][15];
double vis[1<<15][15];

double rec(int st,int la,int we){
  if(st==(1<<la))return 0;
  if(vis[st][la])return dp[st][la];
  vis[st][la]=true;
  double& ret=dp[st][la]=1LL<<30LL;
  rep(i,n){
    if((~st&(1<<i)) || i==la)continue;
    int tdi=abs(dist[i]-dist[la]);
    int twe=we-sen[la]*20;
    double sp=2000/(70.0+twe);
    ret=min(ret,rec(st^(1<<la),i,twe)+tdi/sp);
  }
  return ret;
}

void trace(int st,int la,int we){
  ans.pb(la);
  if(st==(1<<la))return;
  rep(i,n){
    if((~st&(1<<i)) || i==la)continue;
    int tdi=abs(dist[i]-dist[la]);
    int twe=we-sen[la]*20;
    double sp=2000/(70.0+twe);
    if(abs(dp[st][la]-dp[st^(1<<la)][i]-tdi/sp)<EPS){
      trace(st^(1<<la),i,twe);
      return;
    }
  }
}

main(){
  cin>>n;
  int we=0;
  rep(i,n){
    cin>>num[i]>>dist[i]>>sen[i];
    we+=sen[i]*20;
  }
  double mint=rec((1<<n)-1,0,we);
  int st=0;
  rep(i,n)
    if(mint>rec((1<<n)-1,i,we)){
      mint=rec((1<<n)-1,i,we);
      st=i;
    }
  trace((1<<n)-1,st,we);
  reverse(ALL(ans));
  rep(i,SZ(ans)){
    if(i)cout<<' ';
    cout<<num[ans[i]];
  }

}