Given $N$ points in 3D space, sort them by increasing $z$; ties broken by decreasing $y$; further ties by increasing $x$. Print the sorted points.
Input
First line $N$; then $N$ lines each with $x_i$, $y_i$, $z_i$ ($-100000 \le x_i, y_i, z_i \le 100000$). All positions are distinct.
Output
Print each point x y z on its own line, in sorted order.
Example 1
Input
5 1 1 1 3 4 1 1 -1 1 2 2 2 3 3 1
Output
3 4 1 3 3 1 1 1 1 1 -1 1 2 2 2
Discussion
Threads about this problem. Spoilers are collapsed; wrap hints in
||double bars||.No discussion yet. Start a thread if something here needs explaining.