In the year 2040, Minhyeok builds his own kingdom in space consisting of $N$ planets. To rule them efficiently he wants to build tunnels connecting the planets.
Each planet is a point in 3D space. The cost of a tunnel between planets $A(x_A, y_A, z_A)$ and $B(x_B, y_B, z_B)$ is $\min(|x_A - x_B|,\ |y_A - y_B|,\ |z_A - z_B|)$.
Minhyeok wants to build exactly $N-1$ tunnels so that all planets are connected. Write a program that computes the minimum total cost to connect all planets with tunnels.
The first line contains the number of planets $N$ ($1 \le N \le 100,000$). Each of the next $N$ lines contains the $x$, $y$, and $z$ coordinates of a planet. Each coordinate is an integer between $-10^9$ and $10^9$. No two planets share the same position.
Print the minimum total cost to connect all planets with tunnels.