Never trust Ivan (2)

Given nn points on the plane p1pnp_1 \dots p_n no three of which are collinear, find a permutation of the points pi1pinp_{i_1} \dots p_{i_n} such that the nn segments (pi1,pi2),(pi2,pi3),,(pin1,pin),(pin,pi1)(p_{i_1}, p_{i_2}), (p_{i_2}, p_{i_3}), \dots, (p_{i_{n-1}}, p_{i_n}), (p_{i_n}, p_{i_1}) form a non-degenerate polygon, that is, one that does not cross itself.

Input

Input consists of several cases, each one with nn followed by nn points with integer coordinates not larger than 10710^7 in absolute value. Assume 3n1043 \le n \le 10^4, and that no three given points are collinear.

Output

For every case, print a correct polygon constructed from the nn points. If there is more than one solution, print any of them. If there is no solution, print “Ivan is a troll”.

Problem information

Author: Ivan Geffner

Generation: 2026-01-25T11:20:49.653Z

© Jutge.org, 2006–2026.
https://jutge.org