2018湘潭邀请赛F题题解
F. Sorting
Bobo has n tuples (a1, b1, c1), (a2, b2, c2), . . . , (an, bn, cn). He would like to find the lexicographically smallest permutation p1, p2, . . . , pn of 1, 2, . . . , n such that for i ∈ {2, 3, . . . , n} it holds that
Input
The input consists of several test cases and is terminated by end-of-file.
The first line of each test case contains an integer n. The i-th of the following n lines contains 3 integers ai, b