input

4 # how many of those pieces at the bottom

4 2 2 2 2 2 # first number of numbers in this range -1

3 3 3 3 3

2 2 3 4

5 9 9 9 9 9 9

OUTPUT(index output in ascending order)

3 1 2 4

as here is raised to the power of 2 2 3 4

first 3 ^ 4 = 81 then 2 ^ 81 = 2417851639229258349412352

The question is how can you compare these numbers if you raise them to a power and then compare it is not possible? (or rather, but what resources are needed?)))

n = int(input())

h = {}

for i in range(n):

args = list(map(int, input().split()))

args.pop(0)

c = 1

for p in args[::-1]:

c = p ** c

h[i] = c

print(*[x[0] + 1 for x in sorted(h.items(), key=lambda x: x[1])])

https://math.stackexchange.com/questions/101138/complexity-class-of-comparison-of-power-towers