#include <bits/stdc++.h>
using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr ll inf = 10000000000000 ;
string e = "";
ll dp[(2 << 16)][16],ans;
array<int,16> d,m,num;
void init(){
  rep(i,(2<<16)+1){
    rep(j,16)
    dp[i][j] = inf;
  }
  fill(all(d),0);
  fill(all(m),0);
}
ll n;
void bitdp(bitset<16> bit,int k, ll time){
  if(dp[bit.to_ulong()][k] < time) return ;
  if((1 << n) - 1 == bit.to_ulong()){
    dp[bit.to_ulong()][k] = time;
    return ;
  }
  dp[bit.to_ulong()][k] = time;
  rep(i,n){
    if(! bit[i]){
      ll t = time;
      ll dis = abs(d[i]-d[k]);
      ll w = 0;
      rep(j,n){
        if(bit[j])
          w += m[j];
      }
      t += dis * (70 + w);
      bitdp(bit.set(i),i,t);
      bit.reset(i);
    }
  }
}
string str ;
void backtrack(bitset<16> b,int k){
  ll d1 = dp[b.to_ulong()][k];
  if(d1 == inf) return ;
  dp[b.to_ulong()][k] = inf;
  str = " " + to_string(num[k]) + str;
  ll w = 0;
  b.reset(k);
  rep(i,n){
    if(b[i]){
      w += m[i];
    }
  }
  rep(i,n){
    if(i != k){
      ll dis = abs(d[k] - d[i]);
      rep(j,n){
        if(d1 == dis * (70 + w) + dp[b.to_ulong()][i]){
          backtrack(b,i);
        }
      }
    }
  }
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  init();
  cin >> n;
  rep(i,n){
    cin >> num[i] >> d[i] >> m[i];
    m[i] *= 20;
  }
  rep(i,n){
    bitdp((1 << i),i,0);
  }
  ll suf = 0,mi = inf;
  rep(i,n){
    if(mi > dp[(1<<n)-1][i]){
      suf = i;
      mi = dp[(1 << n)-1][i];
    }
  }
  rep(i,n){
    if(i != suf) dp[(1<<n)-1][i] = inf;
  }
  rep(i,n){
    backtrack((1 << n)-1,i);
  }
  str[0] = '\0';
  cout << str << endl;
  return 0;
}