using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    struct Point
    {
        internal int id, dist, wt;
    }

    struct State
    {
        internal int wt, prev;
        internal double time;
    }

    class Problem
    {
        readonly int n;

        Point[] data;
        State[,] dp;

        public Problem(int n)
        {
            this.n = n;

            data = new Point[n];
            dp = new State[1 << n, n];

            for (int i = 0; i < 1 << n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    dp[i, j].time = -1;
                }
            }
        }

        public void MakeData()
        {
            for (int i = 0; i < n; i++)
            {
                string[] input = Console.ReadLine().Split(' ');
                data[i].id = int.Parse(input[0]);
                data[i].dist = int.Parse(input[1]);
                data[i].wt = int.Parse(input[2]);
            }
        }

        public void Solve()
        {
            for (int i = 0; i < n; i++)
            {
                State temp;
                temp.wt = data[i].wt;
                temp.time = 0;
                temp.prev = -1;

                dp[1 << i, i] = temp;
            }

            for (int i = 0; i < 1 << n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    State cur = dp[i, j];

                    if (cur.time == -1) continue;

                    for (int k = 0; k < n; k++)
                    {
                        if ((i & (1 << k)) != 0) continue;

                        State next = dp[i | 1 << k, k];

                        double time = cur.time + Math.Abs(data[j].dist - data[k].dist) * cur.wt;

                        if (next.time == -1 || next.time > time)
                        {
                            State temp;
                            temp.wt = cur.wt + data[k].wt;
                            temp.time = time;
                            temp.prev = j;

                            dp[i | 1 << k, k] = temp;
                        }
                    }
                }
            }

            int s = 0;
            int t = (1 << n) - 1;
            State st = dp[t, s];

            for (int i = 0; i < n; i++)
            {
                if (st.time > dp[t, i].time)
                {
                    st = dp[t, i];
                    s = i;
                }
            }

            Stack<int> stk = new Stack<int>();

            while (s != -1)
            {
                stk.Push(data[s].id);

                int prev = dp[t, s].prev;

                t ^= (1 << s);
                s = prev;
            }

            string ans = "";

            while (stk.Count > 0)
            {
                ans += stk.Pop() + " ";
            }
            Console.WriteLine(ans.TrimEnd());
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            Problem p = new Problem(n);
            p.MakeData();
            p.Solve();
        }
    }
}

Measured memory_bytes: 17736