#P1648. 看守

看守

Description

Given nn points in a dd-dimensional space, find the maximum Manhattan distance between any two points.

For two dd-dimensional points (x1,x2,,xd)(x_1,x_2,\ldots,x_d) and (y1,y2,,yd)(y_1,y_2,\ldots,y_d), their Manhattan distance is defined as x1y1+x2y2++xdyd|x_1-y_1|+|x_2-y_2|+\ldots+|x_d-y_d|.

Input Format

The first line contains two integers nn and dd.

The next nn lines each contain dd integers describing the coordinates of a point.

Output Format

Output the maximum Manhattan distance.

4 2
2 1
1 4
4 5
5 3
6

Hint

Constraints

  • For 60%60\% of the testdata, it is guaranteed that d2d \le 2.
  • For 100%100\% of the testdata, it is guaranteed that 2n1062 \le n \le 10^6, d4d \le 4, and each coordinate satisfies 1xi1051 \le x_i \le 10^5.

Translated by ChatGPT 5