#K58807. Shortest Round Trip Route

    ID: 30724 Type: Default 1000ms 256MiB

Shortest Round Trip Route

Shortest Round Trip Route

You are given a set of points in a 2-dimensional plane. Your task is to determine the shortest possible route that starts from the first point, visits each of the remaining points exactly once, and returns to the starting point. This is a classic Traveling Salesman Problem (TSP) where the distance between two points is defined using the Euclidean distance. The formula for the Euclidean distance between two points \((x_1, y_1)\) and \((x_2, y_2)\) is given by:

\[ d = \sqrt{(x_1-x_2)^2 + (y_1-y_2)^2} \]

You are required to implement an algorithm that finds the shortest route. For small inputs, a brute-force approach that tries all permutations is acceptable.

inputFormat

The first line of input contains a single integer \(n\) representing the number of points (with \(n \geq 2\)). Each of the following \(n\) lines contains two space-separated integers representing the \(x\) and \(y\) coordinates of a point. The first point in the input is the starting point.

outputFormat

Output the sequence of points representing the shortest round-trip route. Each line should contain two integers separated by a space, representing the coordinates of a point. The route must start and end at the first point given in the input.

## sample
4
0 0
2 2
2 0
0 2
0 0

2 0 2 2 0 2 0 0

</p>