#K79837. Minimum Distance to Visit All Points

    ID: 35397 Type: Default 1000ms 256MiB

Minimum Distance to Visit All Points

Minimum Distance to Visit All Points

You are given a sequence of points in the 2D plane. Your task is to calculate the minimum distance required to visit all the points in the given order. Movement is allowed in any of the 8 directions (horizontal, vertical, and diagonal). The distance between two points \(p_1=(x_1,y_1)\) and \(p_2=(x_2,y_2)\) is defined as:

\(d(p_1,p_2)=\max(|x_1-x_2|,\;|y_1-y_2|)\)

You need to compute the total distance by summing the distances between each pair of consecutive points.

inputFormat

The input begins with an integer \(T\) denoting the number of test cases. For each test case, the first line contains an integer \(N\) representing the number of points. The following \(N\) lines each contain two space-separated integers \(x\) and \(y\) which represent the coordinates of a point.

outputFormat

For each test case, output a single line that contains the minimum distance required to visit all points in the order they are provided.

## sample
2
3
1 1
3 3
5 5
2
10 10
20 20
4

10

</p>