#!/usr/bin/env python3

import heapq
class DisjointSets:
    def __init__(self,n):
        self.p = [i for i in range(n)]

    def find(self, u):
        while u != self.p[u]:
            self.p[u] = self.p[self.p[u]]
            u = self.p[u]
        return u

    def union(self, u, v):
        root_u, root_v = self.find(u), self.find(v)
        if root_u == root_v:
            return True
        self.p[root_v] = root_u
        return False


class Heap(object):
    def __init__(self, key):
        self.key = key
        self.index = 0
        self.pq = []

    def push(self, item):
        heapq.heappush(self.pq, (self.key(item), self.index, item))
        self.index += 1

    def pop(self):
        return heapq.heappop(self.pq)[2]
    
    def __len__(self):
        return len(self.pq)

class Node:
    def __init__(self, cost, prob, parent, index):
        self.cost = cost
        self.prob = prob
        self.parent = parent
        self.index = index

n = int(input())
tests = []
for i in range(n):
    tokens = input().split()
    c, p, par = int(tokens[0]), float(tokens[1]), int(tokens[2])
    tests.append(Node(c, 1-p, par-1, i))


ds = DisjointSets(n)
pq = Heap(key=lambda x: x.cost / x.prob)
for i in range(n):
    pq.push(tests[i])


class LinkedListNode:
    def __init__(self, index):
        self.tail = self
        self.next = None
        self.index = index
res = [LinkedListNode(i) for i in range(n)]

used = set()
while len(pq) > 0:
    node = pq.pop()
    if node.index in used:
        continue
    used.add(node.index)
    parent = node.parent
    if parent != -1:
        parent = ds.find(parent)
    if parent == -1 or parent in used:
        cur = res[node.index]
        while cur is not None:
            print(cur.index+1)
            cur = cur.next
    else:
        ds.union(parent, node.index)
        res[parent].tail.next = res[node.index]
        res[parent].tail = res[node.index].tail
        prev = tests[parent]
        prev.cost += (1 - prev.prob) * node.cost
        prev.prob += (1 - prev.prob) * node.prob
        pq.push(prev)
