#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#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()
const int INF = 1<<29;

typedef double Weight;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

// a{ÆÍ\á¤ÀÉÈÁÄ¢éB
// best[S][v] ÍA¸_W S ÌvfðKêÄ v És­Æ«ÌpXÌÅZ£


const int M = 20;
int m[15];

Weight best[1<<M][M];
int    prev[1<<M][M];
void buildPath(int S, int i, vector<int> &path) {
  if (!S) return;
  buildPath(S^(1<<i), prev[S][i], path);
  path.push_back(i);
}
Weight shortestHamiltonPath(Matrix w, int s, vector<int> &path) {
  int n = w.size();
  int N = 1 << n;
  REP(S,N) REP(i,n) best[S][i] = INF;
  best[1<<s][s] = 0;
  REP(S,N) {
    int we = 0;
    REP(i,n) {
      if (S&(1<<i))
        we += m[i];
    }
    REP(i,n)
      if (S&(1<<i))
        REP(j,n) {
          if (best[S|(1<<j)][j] > best[S][i] + w[i][j] * (we + 70)) {
            best[S|(1<<j)][j] = best[S][i] + w[i][j] * (we + 70);
            prev[S|(1<<j)][j] = i;
          }
        }
  }
  int t = min_element(best[N-1], best[N-1]+n) - best[N-1]; // ½ÔÚÌ¸_ÅIíéÌªêÔZ­Èé©
  path.clear(); buildPath(N-1, t, path);
  return best[N-1][t];
}

int main() {
  int n;
  cin >> n;
  int a[n], l[n]; 
  REP(i,n) {
    cin >> a[i] >> l[i] >> m[i];
  }
  Matrix mat(n, Array(n));
  REP(i,n)
    REP(j,n)
      mat[i][j] = abs(l[j]-l[i]);
  int mi = INF;
  vector<int> path;
  REP(i,n) {
    vector<int> tpath;
    int t = shortestHamiltonPath(mat, i, tpath);
    if (t < mi) {
      path = tpath;
      t = mi;
    }
  }
  reverse(ALL(path));
  REP(i, path.size()) {
    if (i)
      cout << " ";
    cout << a[path[i]];
  }
  cout << endl;
}